aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/pkg.go14
-rw-r--r--pkg/pkg_test.go13
2 files changed, 18 insertions, 9 deletions
diff --git a/pkg/pkg.go b/pkg/pkg.go
index 5d9d8d48..75e0d1b1 100644
--- a/pkg/pkg.go
+++ b/pkg/pkg.go
@@ -954,8 +954,9 @@ type ChecksumMismatchError struct {
}
func (e *ChecksumMismatchError) Error() string {
- return "got " + Encode(e.Got) +
- " instead of " + Encode(e.Want)
+ return "unexpected checksum\n" +
+ "\t got: " + Encode(e.Got) + "\n" +
+ "\twant: " + Encode(e.Want)
}
// LinknamePrefixError describes a malformed linkname to a [Checksum].
@@ -1521,7 +1522,7 @@ func (c *Cache) openFile(
id := c.Ident(f)
if c.msg.IsVerbose() {
rn := reportName(f, id)
- c.msg.Verbosef("curing %s%s%s in memory...", c.sgrIdent, rn, c.sgrRes)
+ c.msg.Verbosef("opening %s%s%s...", c.sgrIdent, rn, c.sgrRes)
defer func() {
if err == nil {
c.msg.Verbosef("opened %s%s%s for reading", c.sgrIdent, rn, c.sgrRes)
@@ -2053,6 +2054,9 @@ func WhenceString(whence int) string {
}
}
+// isType returns whether v is of concrete type T.
+func isType[T any](v any) bool { _, ok := v.(T); return ok }
+
// cure implements Cure without acquiring a read lock on abortMu. cure must not
// be entered during Abort.
func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
@@ -2170,7 +2174,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
}
whence = WNew
- if c.msg.IsVerbose() {
+ if c.msg.IsVerbose() && !isType[*Collect](a) {
rn := reportName(a, id)
c.msg.Verbosef("curing %s%s%s...", c.sgrIdent, rn, c.sgrRes)
defer func() {
@@ -2504,7 +2508,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) (
err = f.linkSubstitute(ids, substitutes)
}
if err != nil {
- if c.msg.IsVerbose() {
+ if c.msg.IsVerbose() && !IsCollected(err) {
c.msg.Verbosef(
"cure %s%s%s: %s%v%s",
c.sgrIdent, reportName(ca, id), c.sgrRes,
diff --git a/pkg/pkg_test.go b/pkg/pkg_test.go
index c11b6ac4..aa5016c1 100644
--- a/pkg/pkg_test.go
+++ b/pkg/pkg_test.go
@@ -1794,8 +1794,9 @@ func TestErrors(t *testing.T) {
Want: (pkg.Checksum)(bytes.Repeat([]byte{
0x75, 0xe6, 0x9d, 0x6d, 0xe7, 0x9f,
}, 8)),
- }, "got AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
- " instead of deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"},
+ }, "unexpected checksum\n" +
+ "\t got: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" +
+ "\twant: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"},
{"ResponseStatusError", pkg.ResponseStatusError(
http.StatusNotAcceptable,
@@ -1856,7 +1857,9 @@ func TestScrubError(t *testing.T) {
{"sample", *newWantScrubError(
fhs.AbsVarLib.Append("cure"),
), `checksum mismatches:
-got vsAhtPNo4waRNOASwrQwcIPTqb3SBuJOXw2G4T1mNmVZM-wrQTRllmgXqcIIoRcX instead of _wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+unexpected checksum
+ got: vsAhtPNo4waRNOASwrQwcIPTqb3SBuJOXw2G4T1mNmVZM-wrQTRllmgXqcIIoRcX
+ want: _wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
dangling identifiers:
_gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -1911,7 +1914,9 @@ errors during scrub:
},
},
}, `checksum mismatches:
-got AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA instead of CH3AiUrCCcVOjOYLaMKKK1Da78989JtfHeIsxMzWOQFiN4mrCLDYpoDxLWqJWCUN
+unexpected checksum
+ got: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ want: CH3AiUrCCcVOjOYLaMKKK1Da78989JtfHeIsxMzWOQFiN4mrCLDYpoDxLWqJWCUN
dangling identifiers:
deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef