| ... | ... | @@ -526,7 +526,7 @@ pub const Manifest = struct { |
| 526 | 526 | break :f file; |
| 527 | 527 | } |
| 528 | 528 | const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{}); |
| 529 | | errdefer assert(self.files.popOrNull() != null); |
| 529 | errdefer _ = self.files.pop(); |
| 530 | 530 | if (!gop.found_existing) { |
| 531 | 531 | gop.key_ptr.* = .{ |
| 532 | 532 | .prefixed_path = .{ |
| ... | ... | @@ -633,10 +633,10 @@ pub const Manifest = struct { |
| 633 | 633 | self.hash.hasher.update(&bin_digest); |
| 634 | 634 | |
| 635 | 635 | // Remove files not in the initial hash. |
| 636 | | for (self.files.keys()[input_file_count..]) |*file| { |
| 637 | | file.deinit(self.cache.gpa); |
| 636 | while (self.files.count() != input_file_count) { |
| 637 | var file = self.files.pop(); |
| 638 | file.key.deinit(self.cache.gpa); |
| 638 | 639 | } |
| 639 | | self.files.shrinkRetainingCapacity(input_file_count); |
| 640 | 640 | |
| 641 | 641 | for (self.files.keys()) |file| { |
| 642 | 642 | self.hash.hasher.update(&file.bin_digest); |
| ... | ... | @@ -736,19 +736,27 @@ pub const Manifest = struct { |
| 736 | 736 | const prefixed_path = try self.cache.findPrefix(file_path); |
| 737 | 737 | errdefer gpa.free(prefixed_path.sub_path); |
| 738 | 738 | |
| 739 | | const new_ch_file = try self.files.addOne(gpa); |
| 740 | | new_ch_file.* = .{ |
| 739 | const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{}); |
| 740 | errdefer _ = self.files.pop(); |
| 741 | |
| 742 | if (gop.found_existing) { |
| 743 | gpa.free(prefixed_path.sub_path); |
| 744 | return gop.key_ptr.contents.?; |
| 745 | } |
| 746 | |
| 747 | gop.key_ptr.* = .{ |
| 741 | 748 | .prefixed_path = prefixed_path, |
| 742 | 749 | .max_file_size = max_file_size, |
| 743 | 750 | .stat = undefined, |
| 744 | 751 | .bin_digest = undefined, |
| 745 | 752 | .contents = null, |
| 746 | 753 | }; |
| 747 | | errdefer self.files.shrinkRetainingCapacity(self.files.entries.len - 1); |
| 748 | 754 | |
| 749 | | try self.populateFileHash(new_ch_file); |
| 755 | self.files.lockPointers(); |
| 756 | defer self.files.unlockPointers(); |
| 750 | 757 | |
| 751 | | return new_ch_file.contents.?; |
| 758 | try self.populateFileHash(gop.key_ptr); |
| 759 | return gop.key_ptr.contents.?; |
| 752 | 760 | } |
| 753 | 761 | |
| 754 | 762 | /// Add a file as a dependency of process being cached, after the initial hash has been |
| ... | ... | @@ -765,7 +773,7 @@ pub const Manifest = struct { |
| 765 | 773 | errdefer gpa.free(prefixed_path.sub_path); |
| 766 | 774 | |
| 767 | 775 | const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{}); |
| 768 | | errdefer assert(self.files.popOrNull() != null); |
| 776 | errdefer _ = self.files.pop(); |
| 769 | 777 | |
| 770 | 778 | if (gop.found_existing) { |
| 771 | 779 | gpa.free(prefixed_path.sub_path); |
| ... | ... | @@ -801,7 +809,7 @@ pub const Manifest = struct { |
| 801 | 809 | errdefer gpa.free(prefixed_path.sub_path); |
| 802 | 810 | |
| 803 | 811 | const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{}); |
| 804 | | errdefer assert(self.files.popOrNull() != null); |
| 812 | errdefer _ = self.files.pop(); |
| 805 | 813 | |
| 806 | 814 | if (gop.found_existing) { |
| 807 | 815 | gpa.free(prefixed_path.sub_path); |