authorgravatar for leroycepearson@geemili.xyzLeRoyce Pearson <leroycepearson@geemili.xyz> 2020-04-07 20:19:49-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-25 13:48:43-04:00
logdfb53beb52689519d395541d62519ff01c3d7785
tree942bd71bd8aa8596b904bf1f74fcd939ac5eeb48
parent7917f25b0a8e8d8cafea3bacbb13a3c2b03b9a97

Check if inode matches inode from manifest


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

lib/std/cache_hash.zig+6-4
......@@ -167,10 +167,12 @@ pub const CacheHash = struct {
167167 }
168168
169169 var iter = mem.tokenize(line, " ");
170 const inode = iter.next() orelse return error.InvalidFormat;
170171 const mtime_nsec_str = iter.next() orelse return error.InvalidFormat;
171172 const digest_str = iter.next() orelse return error.InvalidFormat;
172173 const file_path = iter.rest();
173174
175 cache_hash_file.stat.inode = fmt.parseInt(os.ino_t, mtime_nsec_str, 10) catch return error.InvalidFormat;
174176 cache_hash_file.stat.mtime = fmt.parseInt(i64, mtime_nsec_str, 10) catch return error.InvalidFormat;
175177 base64_decoder.decode(&cache_hash_file.bin_digest, digest_str) catch return error.InvalidFormat;
176178
......@@ -189,10 +191,10 @@ pub const CacheHash = struct {
189191 defer this_file.close();
190192
191193 const actual_stat = try this_file.stat();
192 const mtime_matches = actual_stat.mtime == cache_hash_file.stat.mtime;
194 const mtime_match = actual_stat.mtime == cache_hash_file.stat.mtime;
195 const inode_match = actual_stat.inode == cache_hash_file.stat.inode;
193196
194 // TODO: check inode
195 if (!mtime_matches) {
197 if (!mtime_match or !inode_match) {
196198 self.manifest_dirty = true;
197199
198200 cache_hash_file.stat = actual_stat;
......@@ -279,7 +281,7 @@ pub const CacheHash = struct {
279281
280282 for (self.files.toSlice()) |file| {
281283 base64_encoder.encode(encoded_digest[0..], &file.bin_digest);
282 try outStream.print("{} {} {}\n", .{ file.stat.mtime, encoded_digest[0..], file.path });
284 try outStream.print("{} {} {} {}\n", .{ file.stat.inode, file.stat.mtime, encoded_digest[0..], file.path });
283285 }
284286
285287 try self.manifest_file.?.seekTo(0);