aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeRoyce Pearson <leroycepearson@geemili.xyz>2020-04-07 20:19:49 -0600
committerAndrew Kelley <andrew@ziglang.org>2020-05-25 13:48:43 -0400
commitdfb53beb52689519d395541d62519ff01c3d7785 (patch)
tree942bd71bd8aa8596b904bf1f74fcd939ac5eeb48
parent7917f25b0a8e8d8cafea3bacbb13a3c2b03b9a97 (diff)
downloadzig-dfb53beb52689519d395541d62519ff01c3d7785.tar.gz
zig-dfb53beb52689519d395541d62519ff01c3d7785.zip
Check if inode matches inode from manifest
-rw-r--r--lib/std/cache_hash.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig
index c4b1f0f5d0..6da64f9302 100644
--- a/lib/std/cache_hash.zig
+++ b/lib/std/cache_hash.zig
@@ -167,10 +167,12 @@ pub const CacheHash = struct {
}
var iter = mem.tokenize(line, " ");
+ const inode = iter.next() orelse return error.InvalidFormat;
const mtime_nsec_str = iter.next() orelse return error.InvalidFormat;
const digest_str = iter.next() orelse return error.InvalidFormat;
const file_path = iter.rest();
+ cache_hash_file.stat.inode = fmt.parseInt(os.ino_t, mtime_nsec_str, 10) catch return error.InvalidFormat;
cache_hash_file.stat.mtime = fmt.parseInt(i64, mtime_nsec_str, 10) catch return error.InvalidFormat;
base64_decoder.decode(&cache_hash_file.bin_digest, digest_str) catch return error.InvalidFormat;
@@ -189,10 +191,10 @@ pub const CacheHash = struct {
defer this_file.close();
const actual_stat = try this_file.stat();
- const mtime_matches = actual_stat.mtime == cache_hash_file.stat.mtime;
+ const mtime_match = actual_stat.mtime == cache_hash_file.stat.mtime;
+ const inode_match = actual_stat.inode == cache_hash_file.stat.inode;
- // TODO: check inode
- if (!mtime_matches) {
+ if (!mtime_match or !inode_match) {
self.manifest_dirty = true;
cache_hash_file.stat = actual_stat;
@@ -279,7 +281,7 @@ pub const CacheHash = struct {
for (self.files.toSlice()) |file| {
base64_encoder.encode(encoded_digest[0..], &file.bin_digest);
- try outStream.print("{} {} {}\n", .{ file.stat.mtime, encoded_digest[0..], file.path });
+ try outStream.print("{} {} {} {}\n", .{ file.stat.inode, file.stat.mtime, encoded_digest[0..], file.path });
}
try self.manifest_file.?.seekTo(0);