File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,11 @@ pub const Hash = struct {
66
66
67
67
pub fn toSlice (ph : * const Hash ) []const u8 {
68
68
var end : usize = ph .bytes .len ;
69
- while (true ) {
69
+ while (end > 0 ) {
70
70
end -= 1 ;
71
71
if (ph .bytes [end ] != 0 ) return ph .bytes [0 .. end + 1 ];
72
72
}
73
+ return ph .bytes [0.. 0];
73
74
}
74
75
75
76
pub fn eql (a : * const Hash , b : * const Hash ) bool {
@@ -195,6 +196,11 @@ test Hash {
195
196
try std .testing .expectEqualStrings ("nasm-2.16.1-3-vrr-ygAAoADH9XG3tOdvPNuHen_d-XeHndOG-nNXmved" , result .toSlice ());
196
197
}
197
198
199
+ test "empty hash" {
200
+ const hash = Hash .fromSlice ("" );
201
+ try std .testing .expectEqualStrings ("" , hash .toSlice ());
202
+ }
203
+
198
204
test {
199
205
_ = Fetch ;
200
206
}
Original file line number Diff line number Diff line change @@ -568,14 +568,14 @@ fn runResource(
568
568
const actual_hex = Package .multiHashHexDigest (f .computed_hash .digest );
569
569
if (! std .mem .eql (u8 , declared_hash .toSlice (), & actual_hex )) {
570
570
return f .fail (hash_tok , try eb .printString (
571
- "hash mismatch: manifest declares {s} but the fetched package has {s}" ,
571
+ "hash mismatch: manifest declares ' {s}' but the fetched package has ' {s}' " ,
572
572
.{ declared_hash .toSlice (), actual_hex },
573
573
));
574
574
}
575
575
} else {
576
576
if (! computed_package_hash .eql (& declared_hash )) {
577
577
return f .fail (hash_tok , try eb .printString (
578
- "hash mismatch: manifest declares {s} but the fetched package has {s}" ,
578
+ "hash mismatch: manifest declares ' {s}' but the fetched package has ' {s}' " ,
579
579
.{ declared_hash .toSlice (), computed_package_hash .toSlice () },
580
580
));
581
581
}
@@ -726,6 +726,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
726
726
.hash = h : {
727
727
const h = dep .hash orelse break :h null ;
728
728
const pkg_hash : Package.Hash = .fromSlice (h );
729
+ if (h .len == 0 ) break :h pkg_hash ;
729
730
const gop = f .job_queue .table .getOrPutAssumeCapacity (pkg_hash );
730
731
if (gop .found_existing ) {
731
732
if (! dep .lazy ) {
You can’t perform that action at this time.
0 commit comments