| ... | ... | @@ -18,7 +18,6 @@ const BASE64_DIGEST_LEN = base64.Base64Encoder.calcSize(BIN_DIGEST_LEN); |
| 18 | 18 | pub const File = struct { |
| 19 | 19 | path: ?[]const u8, |
| 20 | 20 | stat: fs.File.Stat, |
| 21 | | file_handle: os.fd_t, |
| 22 | 21 | bin_digest: [BIN_DIGEST_LEN]u8, |
| 23 | 22 | contents: ?[]const u8, |
| 24 | 23 | |
| ... | ... | @@ -169,12 +168,10 @@ pub const CacheHash = struct { |
| 169 | 168 | } |
| 170 | 169 | |
| 171 | 170 | var iter = mem.tokenize(line, " "); |
| 172 | | const file_handle_str = iter.next() orelse return error.InvalidFormat; |
| 173 | 171 | const mtime_nsec_str = iter.next() orelse return error.InvalidFormat; |
| 174 | 172 | const digest_str = iter.next() orelse return error.InvalidFormat; |
| 175 | 173 | const file_path = iter.rest(); |
| 176 | 174 | |
| 177 | | cache_hash_file.file_handle = fmt.parseInt(os.fd_t, file_handle_str, 10) catch return error.InvalidFormat; |
| 178 | 175 | cache_hash_file.stat.mtime = fmt.parseInt(i64, mtime_nsec_str, 10) catch return error.InvalidFormat; |
| 179 | 176 | base64_decoder.decode(&cache_hash_file.bin_digest, digest_str) catch return error.InvalidFormat; |
| 180 | 177 | |
| ... | ... | @@ -191,11 +188,16 @@ pub const CacheHash = struct { |
| 191 | 188 | return error.CacheUnavailable; |
| 192 | 189 | }; |
| 193 | 190 | defer this_file.close(); |
| 194 | | cache_hash_file.stat = try this_file.stat(); |
| 195 | | // TODO: check mtime |
| 196 | | if (false) {} else { |
| 191 | |
| 192 | const actual_stat = try this_file.stat(); |
| 193 | const mtime_matches = actual_stat.mtime == cache_hash_file.stat.mtime; |
| 194 | |
| 195 | // TODO: check inode |
| 196 | if (!mtime_matches) { |
| 197 | 197 | self.manifest_dirty = true; |
| 198 | 198 | |
| 199 | cache_hash_file.stat = actual_stat; |
| 200 | |
| 199 | 201 | // TODO: check for problematic timestamp |
| 200 | 202 | |
| 201 | 203 | var actual_digest: [BIN_DIGEST_LEN]u8 = undefined; |
| ... | ... | @@ -277,7 +279,7 @@ pub const CacheHash = struct { |
| 277 | 279 | |
| 278 | 280 | for (self.files.toSlice()) |file| { |
| 279 | 281 | base64_encoder.encode(encoded_digest[0..], &file.bin_digest); |
| 280 | | try contents.print("{} {} {} {}\n", .{ file.file_handle, file.stat.mtime, encoded_digest[0..], file.path }); |
| 282 | try contents.print("{} {} {}\n", .{ file.stat.mtime, encoded_digest[0..], file.path }); |
| 281 | 283 | } |
| 282 | 284 | |
| 283 | 285 | try self.manifest_file.?.seekTo(0); |