addFilePost
Add a file as a dependency of process being cached, after the initial hash has been calculated.
This is useful for processes that don't know the all the files that are depended on ahead of time. For example, a source file that can import other files will need to be recompiled if the imported file is changed.
Function parameters
Parameters
- self:*Manifest
- file_path:[]const u8
Type definitions in this namespace
Types
Functions in this namespace
Functions
- obtain
- Be sure to call `Manifest.deinit` after successful initialization.
- readSmallFile
- On operating systems that support symlinks, does a readlink.
- writeSmallFile
- On operating systems that support symlinks, does a symlink.
This is 128 bits - Even with 2^54 cache entries, the probably of a collision would be under 10^-6
Values
- bin_digest_len
- This is 128 bits - Even with 2^54 cache entries, the probably of a collision would be under 10^-6
- hex_digest_len
- = bin_digest_len * 2
- hasher_init
- Initial state with random bytes, that can be copied.
Source
Implementation
pub fn addFilePost(self: *Manifest, file_path: []const u8) !void {
assert(self.manifest_file != null);
const gpa = self.cache.gpa;
const prefixed_path = try self.cache.findPrefix(file_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;
}
gop.key_ptr.* = .{
.prefixed_path = prefixed_path,
.max_file_size = null,
.handle = null,
.stat = undefined,
.bin_digest = undefined,
.contents = null,
};
self.files.lockPointers();
defer self.files.unlockPointers();
try self.populateFileHash(gop.key_ptr);
}