| ... | @@ -528,14 +528,15 @@ pub const Manifest = struct { | ... | @@ -528,14 +528,15 @@ pub const Manifest = struct { |
| 528 | } | 528 | } |
| 529 | | 529 | |
| 530 | pub fn writeManifest(self: *Manifest) !void { | 530 | pub fn writeManifest(self: *Manifest) !void { |
| 531 | assert(self.manifest_file != null); | 531 | const manifest_file = self.manifest_file.?; |
| 532 | if (!self.manifest_dirty) return; | 532 | if (!self.manifest_dirty) return; |
| 533 | | 533 | |
| 534 | var encoded_digest: [hex_digest_len]u8 = undefined; | | |
| 535 | var contents = std.ArrayList(u8).init(self.cache.gpa); | 534 | var contents = std.ArrayList(u8).init(self.cache.gpa); |
| 536 | var writer = contents.writer(); | | |
| 537 | defer contents.deinit(); | 535 | defer contents.deinit(); |
| 538 | | 536 | |
| | 537 | const writer = contents.writer(); |
| | 538 | var encoded_digest: [hex_digest_len]u8 = undefined; |
| | 539 | |
| 539 | for (self.files.items) |file| { | 540 | for (self.files.items) |file| { |
| 540 | _ = std.fmt.bufPrint(&encoded_digest, "{x}", .{file.bin_digest}) catch unreachable; | 541 | _ = std.fmt.bufPrint(&encoded_digest, "{x}", .{file.bin_digest}) catch unreachable; |
| 541 | try writer.print("{d} {d} {d} {s} {s}\n", .{ | 542 | try writer.print("{d} {d} {d} {s} {s}\n", .{ |
| ... | @@ -547,7 +548,8 @@ pub const Manifest = struct { | ... | @@ -547,7 +548,8 @@ pub const Manifest = struct { |
| 547 | }); | 548 | }); |
| 548 | } | 549 | } |
| 549 | | 550 | |
| 550 | try self.manifest_file.?.pwriteAll(contents.items, 0); | 551 | try manifest_file.setEndPos(contents.items.len); |
| | 552 | try manifest_file.pwriteAll(contents.items, 0); |
| 551 | self.manifest_dirty = false; | 553 | self.manifest_dirty = false; |
| 552 | } | 554 | } |
| 553 | | 555 | |