aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-07-04 23:46:50 +0900
committerOphestra <cat@gensokyo.uk>2026-07-04 23:46:50 +0900
commit512d9b95bd271c0d4a5e8e8b6fc5d578d847d37e (patch)
treebe8267cd13255aac8303f5bae5b88af5d3360eac /internal
parent5bf87561f52c29dd0159a9828f999a021508f85e (diff)
internal/pkg: remove status acquisition from extern helper
Doing this together just makes it awkward to query status early, having to deal with cleaning up. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/pkg.go31
1 files changed, 12 insertions, 19 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 489e34f4..78e62e85 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -1881,11 +1881,7 @@ func (c *Cache) tryLocal(id unique.Handle[ID]) (unique.Handle[Checksum], error)
}
// tryExtern attempts to obtain an [Artifact] outcome from extern.
-func (c *Cache) tryExtern(
- ctx context.Context,
- id unique.Handle[ID],
- status *io.ReadCloser,
-) (
+func (c *Cache) tryExtern(ctx context.Context, id unique.Handle[ID]) (
unique.Handle[Checksum],
error,
) {
@@ -1914,12 +1910,7 @@ func (c *Cache) tryExtern(
return zeroChecksum, &ChecksumMismatchError{got.Value(), checksum.Value()}
}
}
-
- var err error
- if status != nil {
- *status, err = c.extern.Status(&RContext{common{ctx, c}}, id)
- }
- return checksum, err
+ return checksum, nil
}
// cureMany concurrently collects outcome of multiple [Artifact].
@@ -2254,11 +2245,8 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
defer f.destroy(&err)
- var (
- externChecksum unique.Handle[Checksum]
- externStatus io.ReadCloser
- )
- if externChecksum, err = c.tryExtern(ctx, id, &externStatus); err != nil {
+ var externChecksum unique.Handle[Checksum]
+ if externChecksum, err = c.tryExtern(ctx, id); err != nil {
if c.msg.IsVerbose() {
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
}
@@ -2266,9 +2254,6 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
}
if externChecksum != zeroChecksum {
if checksum != zeroChecksum && externChecksum != checksum {
- if externStatus != nil {
- _ = externStatus.Close()
- }
err = &ChecksumMismatchError{externChecksum.Value(), checksum.Value()}
if c.msg.IsVerbose() {
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
@@ -2276,6 +2261,14 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
return
}
+ var externStatus io.ReadCloser
+ c.externMu.RLock()
+ externStatus, err = c.extern.Status(&RContext{common{ctx, c}}, id)
+ c.externMu.RUnlock()
+ if err != nil {
+ return
+ }
+
checksum = externChecksum
checksums = Encode(checksum.Value())
checksumPathname = c.base.Append(