authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-04-11 15:24:20-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-25 13:48:43-04:00
log73d2747084e92b2907ecf71f180a955ec411975e
tree7e4e8a9e0384d8b52ed2a93e337a308191d51fff
parent204aa7dc1a183bb5fba91328d4f436c6f91471af

Open file with exclusive lock


1 files changed, 6 insertions(+), 2 deletions(-)

lib/std/cache_hash.zig+6-2
...@@ -139,7 +139,11 @@ pub const CacheHash = struct {...@@ -139,7 +139,11 @@ pub const CacheHash = struct {
139 const manifest_file_path = try fmt.allocPrint(self.alloc, "{}.txt", .{self.b64_digest});139 const manifest_file_path = try fmt.allocPrint(self.alloc, "{}.txt", .{self.b64_digest});
140 defer self.alloc.free(manifest_file_path);140 defer self.alloc.free(manifest_file_path);
141141
142 self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{ .read = true, .truncate = false });142 self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{
143 .read = true,
144 .truncate = false,
145 .lock = .Exclusive,
146 });
143 }147 }
144148
145 // TODO: Figure out a good max value?149 // TODO: Figure out a good max value?
...@@ -213,7 +217,7 @@ pub const CacheHash = struct {...@@ -213,7 +217,7 @@ pub const CacheHash = struct {
213217
214 if (any_file_changed) {218 if (any_file_changed) {
215 // cache miss219 // cache miss
216 // keep the manifest file open (TODO: with rw lock)220 // keep the manifest file open
217 // reset the hash221 // reset the hash
218 self.blake3 = Blake3.init();222 self.blake3 = Blake3.init();
219 self.blake3.update(&bin_digest);223 self.blake3.update(&bin_digest);