| ... | ... | @@ -11,10 +11,8 @@ const Allocator = mem.Allocator; |
| 11 | 11 | const Buffer = @import("buffer.zig").Buffer; |
| 12 | 12 | const os = @import("os.zig"); |
| 13 | 13 | |
| 14 | | const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; |
| 15 | | const base64_pad_char = '='; |
| 16 | | const encoder = base64.Base64Encoder.init(base64_alphabet, base64_pad_char); |
| 17 | | const decoder = base64.Base64Decoder.init(base64_alphabet, base64_pad_char); |
| 14 | const base64_encoder = fs.base64_encoder; |
| 15 | const base64_decoder = fs.base64_decoder; |
| 18 | 16 | const BIN_DIGEST_LEN = 32; |
| 19 | 17 | |
| 20 | 18 | pub const CacheHashFile = struct { |
| ... | ... | @@ -107,7 +105,7 @@ pub const CacheHash = struct { |
| 107 | 105 | |
| 108 | 106 | const OUT_DIGEST_LEN = base64.Base64Encoder.calcSize(BIN_DIGEST_LEN); |
| 109 | 107 | try self.b64_digest.resize(OUT_DIGEST_LEN); |
| 110 | | encoder.encode(self.b64_digest.toSlice(), &bin_digest); |
| 108 | base64_encoder.encode(self.b64_digest.toSlice(), &bin_digest); |
| 111 | 109 | |
| 112 | 110 | if (self.files.toSlice().len == 0 and !self.force_check_manifest) { |
| 113 | 111 | try out_digest.resize(OUT_DIGEST_LEN); |
| ... | ... | @@ -166,7 +164,7 @@ pub const CacheHash = struct { |
| 166 | 164 | |
| 167 | 165 | cache_hash_file.file_handle = fmt.parseInt(os.fd_t, file_handle_str, 10) catch return error.InvalidFormat; |
| 168 | 166 | cache_hash_file.stat.mtime = fmt.parseInt(i64, mtime_nsec_str, 10) catch return error.InvalidFormat; |
| 169 | | decoder.decode(&cache_hash_file.bin_digest, digest_str) catch return error.InvalidFormat; |
| 167 | base64_decoder.decode(&cache_hash_file.bin_digest, digest_str) catch return error.InvalidFormat; |
| 170 | 168 | |
| 171 | 169 | if (file_path.len == 0) { |
| 172 | 170 | return error.InvalidFormat; |
| ... | ... | @@ -255,7 +253,7 @@ pub const CacheHash = struct { |
| 255 | 253 | |
| 256 | 254 | const OUT_DIGEST_LEN = base64.Base64Encoder.calcSize(BIN_DIGEST_LEN); |
| 257 | 255 | try out_digest.resize(OUT_DIGEST_LEN); |
| 258 | | encoder.encode(out_digest.toSlice(), &bin_digest); |
| 256 | base64_encoder.encode(out_digest.toSlice(), &bin_digest); |
| 259 | 257 | } |
| 260 | 258 | |
| 261 | 259 | pub fn write_manifest(self: *@This()) !void { |
| ... | ... | @@ -268,7 +266,7 @@ pub const CacheHash = struct { |
| 268 | 266 | defer contents.deinit(); |
| 269 | 267 | |
| 270 | 268 | for (self.files.toSlice()) |file| { |
| 271 | | encoder.encode(encoded_digest.toSlice(), &file.bin_digest); |
| 269 | base64_encoder.encode(encoded_digest.toSlice(), &file.bin_digest); |
| 272 | 270 | try contents.print("{} {} {} {}\n", .{ file.file_handle, file.stat.mtime, encoded_digest.toSlice(), file.path }); |
| 273 | 271 | } |
| 274 | 272 | |