| ... | ... | @@ -499,9 +499,10 @@ pub const Manifest = struct { |
| 499 | 499 | pub fn flagsAndPath(off: File.Offset, contents: []const u8) [:0]const u8 { |
| 500 | 500 | const flags_off = @offsetOf(File, "flags"); |
| 501 | 501 | comptime assert(@offsetOf(File, "path_start") - flags_off == 1); |
| 502 | | const hash_start = @backingInt(off) + flags_off; |
| 503 | | const hash_end = mem.findScalarPos(u8, contents, hash_start, 0).?; |
| 504 | | return contents[hash_start..hash_end :0]; |
| 502 | const start = @backingInt(off) + flags_off; |
| 503 | // Scan for the sentinel starting from the path_start offset because flags might be zero. |
| 504 | const end = mem.findScalarPos(u8, contents, start + 1, 0).?; |
| 505 | return contents[start..end :0]; |
| 505 | 506 | } |
| 506 | 507 | |
| 507 | 508 | pub fn pathFallible(off: File.Offset, contents: []const u8) error{InvalidFormat}![:0]const u8 { |
| ... | ... | @@ -898,7 +899,8 @@ pub const Manifest = struct { |
| 898 | 899 | // This is *not* hashing the contents of the input files. It is the |
| 899 | 900 | // flags (including prefix) and path only. |
| 900 | 901 | for (man.files.keys()[0..man.input_paths.items.len]) |file_off| { |
| 901 | | man.hashFlagsAndPath(file_off, &man.hash.hasher); |
| 902 | const flags_and_path = file_off.flagsAndPath(man.contents.items); |
| 903 | man.hash.hasher.update(mem.absorbSentinel(flags_and_path)); |
| 902 | 904 | } |
| 903 | 905 | |
| 904 | 906 | var input_digest: BinDigest = undefined; |
| ... | ... | @@ -2288,10 +2290,6 @@ pub const Manifest = struct { |
| 2288 | 2290 | hasher.update(contents.items[contents_start..][0..contents_len]); |
| 2289 | 2291 | hasher.final(bin_digest); |
| 2290 | 2292 | } |
| 2291 | | |
| 2292 | | fn hashFlagsAndPath(m: *const Manifest, off: File.Offset, hasher: *Hasher) void { |
| 2293 | | hasher.update(off.flagsAndPath(m.contents.items)); |
| 2294 | | } |
| 2295 | 2293 | }; |
| 2296 | 2294 | |
| 2297 | 2295 | /// Create/Write a file, close it, then grab its stat.mtime timestamp. |