stage2: fix Cache not calling ftruncate in writeManifest
this led to a corrupt cache when the number of files got smaller. it is now fixed.master
parent
ef9582a1ec
commit
73167e80f8
|
@ -1,4 +1,3 @@
|
|||
* docs are failing to build
|
||||
* MachO LLD linking
|
||||
* WASM LLD linking
|
||||
* audit the CLI options for stage2
|
||||
|
|
|
@ -528,14 +528,15 @@ pub const Manifest = struct {
|
|||
}
|
||||
|
||||
pub fn writeManifest(self: *Manifest) !void {
|
||||
assert(self.manifest_file != null);
|
||||
const manifest_file = self.manifest_file.?;
|
||||
if (!self.manifest_dirty) return;
|
||||
|
||||
var encoded_digest: [hex_digest_len]u8 = undefined;
|
||||
var contents = std.ArrayList(u8).init(self.cache.gpa);
|
||||
var writer = contents.writer();
|
||||
defer contents.deinit();
|
||||
|
||||
const writer = contents.writer();
|
||||
var encoded_digest: [hex_digest_len]u8 = undefined;
|
||||
|
||||
for (self.files.items) |file| {
|
||||
_ = std.fmt.bufPrint(&encoded_digest, "{x}", .{file.bin_digest}) catch unreachable;
|
||||
try writer.print("{d} {d} {d} {s} {s}\n", .{
|
||||
|
@ -547,7 +548,8 @@ pub const Manifest = struct {
|
|||
});
|
||||
}
|
||||
|
||||
try self.manifest_file.?.pwriteAll(contents.items, 0);
|
||||
try manifest_file.setEndPos(contents.items.len);
|
||||
try manifest_file.pwriteAll(contents.items, 0);
|
||||
self.manifest_dirty = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue