From dfb53beb52689519d395541d62519ff01c3d7785 Mon Sep 17 00:00:00 2001 From: LeRoyce Pearson Date: Tue, 7 Apr 2020 20:19:49 -0600 Subject: Check if inode matches inode from manifest --- lib/std/cache_hash.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/std/cache_hash.zig') 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); -- cgit v1.2.3