internal/pkg: remove status acquisition from extern helper
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m59s
Test / Hakurei (push) Successful in 4m2s
Test / ShareFS (push) Successful in 4m4s
Test / Sandbox (race detector) (push) Successful in 5m42s
Test / Hakurei (race detector) (push) Successful in 6m45s
Test / Flake checks (push) Successful in 1m11s
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m59s
Test / Hakurei (push) Successful in 4m2s
Test / ShareFS (push) Successful in 4m4s
Test / Sandbox (race detector) (push) Successful in 5m42s
Test / Hakurei (race detector) (push) Successful in 6m45s
Test / Flake checks (push) Successful in 1m11s
Doing this together just makes it awkward to query status early, having to deal with cleaning up. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+12
-19
@@ -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.
|
// tryExtern attempts to obtain an [Artifact] outcome from extern.
|
||||||
func (c *Cache) tryExtern(
|
func (c *Cache) tryExtern(ctx context.Context, id unique.Handle[ID]) (
|
||||||
ctx context.Context,
|
|
||||||
id unique.Handle[ID],
|
|
||||||
status *io.ReadCloser,
|
|
||||||
) (
|
|
||||||
unique.Handle[Checksum],
|
unique.Handle[Checksum],
|
||||||
error,
|
error,
|
||||||
) {
|
) {
|
||||||
@@ -1914,12 +1910,7 @@ func (c *Cache) tryExtern(
|
|||||||
return zeroChecksum, &ChecksumMismatchError{got.Value(), checksum.Value()}
|
return zeroChecksum, &ChecksumMismatchError{got.Value(), checksum.Value()}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return checksum, nil
|
||||||
var err error
|
|
||||||
if status != nil {
|
|
||||||
*status, err = c.extern.Status(&RContext{common{ctx, c}}, id)
|
|
||||||
}
|
|
||||||
return checksum, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cureMany concurrently collects outcome of multiple [Artifact].
|
// cureMany concurrently collects outcome of multiple [Artifact].
|
||||||
@@ -2254,11 +2245,8 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
|
|||||||
|
|
||||||
defer f.destroy(&err)
|
defer f.destroy(&err)
|
||||||
|
|
||||||
var (
|
var externChecksum unique.Handle[Checksum]
|
||||||
externChecksum unique.Handle[Checksum]
|
if externChecksum, err = c.tryExtern(ctx, id); err != nil {
|
||||||
externStatus io.ReadCloser
|
|
||||||
)
|
|
||||||
if externChecksum, err = c.tryExtern(ctx, id, &externStatus); err != nil {
|
|
||||||
if c.msg.IsVerbose() {
|
if c.msg.IsVerbose() {
|
||||||
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
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 externChecksum != zeroChecksum {
|
||||||
if checksum != zeroChecksum && externChecksum != checksum {
|
if checksum != zeroChecksum && externChecksum != checksum {
|
||||||
if externStatus != nil {
|
|
||||||
_ = externStatus.Close()
|
|
||||||
}
|
|
||||||
err = &ChecksumMismatchError{externChecksum.Value(), checksum.Value()}
|
err = &ChecksumMismatchError{externChecksum.Value(), checksum.Value()}
|
||||||
if c.msg.IsVerbose() {
|
if c.msg.IsVerbose() {
|
||||||
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
c.msg.Verbosef("extern %s: %v", reportName(ca, id), err)
|
||||||
@@ -2276,6 +2261,14 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
|
|||||||
return
|
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
|
checksum = externChecksum
|
||||||
checksums = Encode(checksum.Value())
|
checksums = Encode(checksum.Value())
|
||||||
checksumPathname = c.base.Append(
|
checksumPathname = c.base.Append(
|
||||||
|
|||||||
Reference in New Issue
Block a user