internal/pkg: expose extra methods to file

This is useful for FileArtifact processing another stream.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-15 00:45:37 +09:00
parent 5828631e79
commit 4f570cc5c9

View File

@@ -196,14 +196,7 @@ func (f *FContext) GetArtifact(a Artifact) (
//
// Methods of RContext are safe for concurrent use. RContext is valid
// until [FileArtifact.Cure] returns.
type RContext struct {
// Address of underlying [Cache], should be zeroed or made unusable after
// [FileArtifact.Cure] returns and must not be exposed directly.
cache *Cache
}
// Unwrap returns the underlying [context.Context].
func (r *RContext) Unwrap() context.Context { return r.cache.ctx }
type RContext struct{ common }
// An Artifact is a read-only reference to a piece of data that may be created
// deterministically but might not currently be available in memory or on the
@@ -959,7 +952,7 @@ func (c *Cache) openFile(f FileArtifact) (r io.ReadCloser, err error) {
}
}()
}
return f.Cure(&RContext{c})
return f.Cure(&RContext{common{c}})
}
return
}
@@ -1455,7 +1448,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
if err = c.enterCure(a, curesExempt); err != nil {
return
}
r, err = f.Cure(&RContext{c})
r, err = f.Cure(&RContext{common{c}})
if err == nil {
if checksumPathname == nil || c.IsStrict() {
h := sha512.New384()