hash mismatch error: don't make empty such a special case

we can more simply use quotes instead
This commit is contained in:
Andrew Kelley 2025-06-06 11:16:44 -07:00
parent 8f7fc63847
commit bc3ce4b971

View file

@ -567,18 +567,16 @@ fn runResource(
if (declared_hash.isOld()) {
const actual_hex = Package.multiHashHexDigest(f.computed_hash.digest);
if (!std.mem.eql(u8, declared_hash.toSlice(), &actual_hex)) {
const declared = if (declared_hash.toSlice().len > 0) declared_hash.toSlice() else "<empty>";
return f.fail(hash_tok, try eb.printString(
"hash mismatch: manifest declares {s} but the fetched package has {s}",
.{ declared, actual_hex },
"hash mismatch: manifest declares '{s}' but the fetched package has '{s}'",
.{ declared_hash.toSlice(), actual_hex },
));
}
} else {
if (!computed_package_hash.eql(&declared_hash)) {
const declared = if (declared_hash.toSlice().len > 0) declared_hash.toSlice() else "<empty>";
return f.fail(hash_tok, try eb.printString(
"hash mismatch: manifest declares {s} but the fetched package has {s}",
.{ declared, computed_package_hash.toSlice() },
"hash mismatch: manifest declares '{s}' but the fetched package has '{s}'",
.{ declared_hash.toSlice(), computed_package_hash.toSlice() },
));
}
}