From 73d2747084e92b2907ecf71f180a955ec411975e Mon Sep 17 00:00:00 2001 From: LeRoyce Pearson Date: Sat, 11 Apr 2020 15:24:20 -0600 Subject: [PATCH] Open file with exclusive lock --- lib/std/cache_hash.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig index f63db444cf..c4610480f3 100644 --- a/lib/std/cache_hash.zig +++ b/lib/std/cache_hash.zig @@ -139,7 +139,11 @@ pub const CacheHash = struct { const manifest_file_path = try fmt.allocPrint(self.alloc, "{}.txt", .{self.b64_digest}); defer self.alloc.free(manifest_file_path); - self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{ .read = true, .truncate = false }); + self.manifest_file = try self.manifest_dir.createFile(manifest_file_path, .{ + .read = true, + .truncate = false, + .lock = .Exclusive, + }); } // TODO: Figure out a good max value? @@ -213,7 +217,7 @@ pub const CacheHash = struct { if (any_file_changed) { // cache miss - // keep the manifest file open (TODO: with rw lock) + // keep the manifest file open // reset the hash self.blake3 = Blake3.init(); self.blake3.update(&bin_digest);