Function writeManifest [src]
If want_shared_lock is true, this function automatically downgrades the
lock from exclusive to shared.
Prototype
pub fn writeManifest(self: *Manifest) !void
Parameters
self: *Manifest
Source
pub fn writeManifest(self: *Manifest) !void {
assert(self.have_exclusive_lock);
const manifest_file = self.manifest_file.?;
if (self.manifest_dirty) {
self.manifest_dirty = false;
var contents = std.ArrayList(u8).init(self.cache.gpa);
defer contents.deinit();
const writer = contents.writer();
try writer.writeAll(manifest_header ++ "\n");
for (self.files.keys()) |file| {
try writer.print("{d} {d} {d} {} {d} {s}\n", .{
file.stat.size,
file.stat.inode,
file.stat.mtime,
fmt.fmtSliceHexLower(&file.bin_digest),
file.prefixed_path.prefix,
file.prefixed_path.sub_path,
});
}
try manifest_file.setEndPos(contents.items.len);
try manifest_file.pwriteAll(contents.items, 0);
}
if (self.want_shared_lock) {
try self.downgradeToSharedLock();
}
}