| ... | ... | @@ -194,6 +194,9 @@ pub const Manifest = struct { |
| 194 | 194 | files: std.ArrayListUnmanaged(File) = .{}, |
| 195 | 195 | hex_digest: [hex_digest_len]u8, |
| 196 | 196 | debug_bin_digest: DebugBinDigest = null_debug_bin_digest, |
| 197 | /// Populated when hit() returns an error because of one |
| 198 | /// of the files listed in the manifest. |
| 199 | failed_file_index: ?usize = null, |
| 197 | 200 | |
| 198 | 201 | /// Add a file as a dependency of process being cached. When `hit` is |
| 199 | 202 | /// called, the file's contents will be checked to ensure that it matches |
| ... | ... | @@ -255,6 +258,8 @@ pub const Manifest = struct { |
| 255 | 258 | pub fn hit(self: *Manifest) !bool { |
| 256 | 259 | assert(self.manifest_file == null); |
| 257 | 260 | |
| 261 | self.failed_file_index = null; |
| 262 | |
| 258 | 263 | const ext = ".txt"; |
| 259 | 264 | var manifest_file_path: [self.hex_digest.len + ext.len]u8 = undefined; |
| 260 | 265 | |
| ... | ... | @@ -366,7 +371,10 @@ pub const Manifest = struct { |
| 366 | 371 | }; |
| 367 | 372 | defer this_file.close(); |
| 368 | 373 | |
| 369 | | const actual_stat = try this_file.stat(); |
| 374 | const actual_stat = this_file.stat() catch |err| { |
| 375 | self.failed_file_index = idx; |
| 376 | return err; |
| 377 | }; |
| 370 | 378 | const size_match = actual_stat.size == cache_hash_file.stat.size; |
| 371 | 379 | const mtime_match = actual_stat.mtime == cache_hash_file.stat.mtime; |
| 372 | 380 | const inode_match = actual_stat.inode == cache_hash_file.stat.inode; |
| ... | ... | @@ -382,7 +390,10 @@ pub const Manifest = struct { |
| 382 | 390 | } |
| 383 | 391 | |
| 384 | 392 | var actual_digest: BinDigest = undefined; |
| 385 | | try hashFile(this_file, &actual_digest); |
| 393 | hashFile(this_file, &actual_digest) catch |err| { |
| 394 | self.failed_file_index = idx; |
| 395 | return err; |
| 396 | }; |
| 386 | 397 | |
| 387 | 398 | if (!mem.eql(u8, &cache_hash_file.bin_digest, &actual_digest)) { |
| 388 | 399 | cache_hash_file.bin_digest = actual_digest; |
| ... | ... | @@ -407,7 +418,10 @@ pub const Manifest = struct { |
| 407 | 418 | self.manifest_dirty = true; |
| 408 | 419 | while (idx < input_file_count) : (idx += 1) { |
| 409 | 420 | const ch_file = &self.files.items[idx]; |
| 410 | | try self.populateFileHash(ch_file); |
| 421 | self.populateFileHash(ch_file) catch |err| { |
| 422 | self.failed_file_index = idx; |
| 423 | return err; |
| 424 | }; |
| 411 | 425 | } |
| 412 | 426 | return false; |
| 413 | 427 | } |