internal/pkg: make checksum available to cure
All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m41s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hpkg (push) Successful in 5m37s
Test / Hakurei (push) Successful in 5m49s
Test / Hakurei (race detector) (push) Successful in 7m27s
Test / Flake checks (push) Successful in 1m43s

This enables deduplication by value as implemented in execArtifact.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-19 20:10:51 +09:00
parent 1c49c75f95
commit d933234784
8 changed files with 195 additions and 71 deletions

View File

@@ -159,7 +159,7 @@ func destroyArtifact(
} else {
p := base.Append(
"checksum",
pkg.Encode(checksum),
pkg.Encode(checksum.Value()),
)
if err = filepath.WalkDir(p.String(), func(
path string,
@@ -362,20 +362,34 @@ var ignorePathname = check.MustAbs("/\x00")
func cureMany(t *testing.T, c *pkg.Cache, steps []cureStep) {
t.Helper()
makeChecksumH := func(checksum pkg.Checksum) unique.Handle[pkg.Checksum] {
if checksum == (pkg.Checksum{}) {
return unique.Handle[pkg.Checksum]{}
}
return unique.Make(checksum)
}
for _, step := range steps {
t.Log("cure step:", step.name)
if pathname, checksum, err := c.Cure(step.a); !reflect.DeepEqual(err, step.err) {
t.Fatalf("Cure: error = %v, want %v", err, step.err)
} else if step.pathname != ignorePathname && !pathname.Is(step.pathname) {
t.Fatalf("Cure: pathname = %q, want %q", pathname, step.pathname)
} else if checksum != step.checksum {
t.Fatalf("Cure: checksum = %s, want %s", pkg.Encode(checksum), pkg.Encode(step.checksum))
} else if checksum != makeChecksumH(step.checksum) {
t.Fatalf(
"Cure: checksum = %s, want %s",
pkg.Encode(checksum.Value()), pkg.Encode(step.checksum),
)
} else {
v := any(err)
if err == nil {
v = pathname
}
t.Log(pkg.Encode(checksum)+":", v)
var checksumVal pkg.Checksum
if checksum != (unique.Handle[pkg.Checksum]{}) {
checksumVal = checksum.Value()
}
t.Log(pkg.Encode(checksumVal)+":", v)
}
}
}