internal/pkg: expose extra methods to file
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m38s
Test / Hakurei (push) Successful in 3m56s
Test / ShareFS (push) Successful in 4m3s
Test / Hpkg (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 5m8s
Test / Hakurei (race detector) (push) Successful in 5m56s
Test / Flake checks (push) Successful in 1m45s
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m38s
Test / Hakurei (push) Successful in 3m56s
Test / ShareFS (push) Successful in 4m3s
Test / Hpkg (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 5m8s
Test / Hakurei (race detector) (push) Successful in 5m56s
Test / Flake checks (push) Successful in 1m45s
This is useful for FileArtifact processing another stream. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -196,14 +196,7 @@ func (f *FContext) GetArtifact(a Artifact) (
|
|||||||
//
|
//
|
||||||
// Methods of RContext are safe for concurrent use. RContext is valid
|
// Methods of RContext are safe for concurrent use. RContext is valid
|
||||||
// until [FileArtifact.Cure] returns.
|
// until [FileArtifact.Cure] returns.
|
||||||
type RContext struct {
|
type RContext struct{ common }
|
||||||
// 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 }
|
|
||||||
|
|
||||||
// An Artifact is a read-only reference to a piece of data that may be created
|
// 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
|
// 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
|
return
|
||||||
}
|
}
|
||||||
@@ -1455,7 +1448,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
|
|||||||
if err = c.enterCure(a, curesExempt); err != nil {
|
if err = c.enterCure(a, curesExempt); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r, err = f.Cure(&RContext{c})
|
r, err = f.Cure(&RContext{common{c}})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if checksumPathname == nil || c.IsStrict() {
|
if checksumPathname == nil || c.IsStrict() {
|
||||||
h := sha512.New384()
|
h := sha512.New384()
|
||||||
|
|||||||
Reference in New Issue
Block a user