Function addFilePostContents [src]
Like addFilePost but when the file contents have already been loaded from disk.
On success, cache takes ownership of resolved_path.
Prototype
pub fn addFilePostContents( self: *Manifest, resolved_path: []u8, bytes: []const u8, stat: File.Stat, ) !void
Parameters
self: *Manifest
resolved_path: []u8
bytes: []const u8
stat: File.Stat
Source
pub fn addFilePostContents(
self: *Manifest,
resolved_path: []u8,
bytes: []const u8,
stat: File.Stat,
) !void {
assert(self.manifest_file != null);
const gpa = self.cache.gpa;
const prefixed_path = try self.cache.findPrefixResolved(resolved_path);
errdefer gpa.free(prefixed_path.sub_path);
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
errdefer _ = self.files.pop();
if (gop.found_existing) {
gpa.free(prefixed_path.sub_path);
return;
}
const new_file = gop.key_ptr;
new_file.* = .{
.prefixed_path = prefixed_path,
.max_file_size = null,
.handle = null,
.stat = stat,
.bin_digest = undefined,
.contents = null,
};
if (self.isProblematicTimestamp(new_file.stat.mtime)) {
// The actual file has an unreliable timestamp, force it to be hashed
new_file.stat.mtime = 0;
new_file.stat.inode = 0;
}
{
var hasher = hasher_init;
hasher.update(bytes);
hasher.final(&new_file.bin_digest);
}
self.hash.hasher.update(&new_file.bin_digest);
}