1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-08 18:11:02 +01:00

fetchToStore(): Fix caching

This was broken because MountedSourceAccessor did not return a
fingerprint. Previously fingerprints were global to an accessor, but
with a MountedSourceAccessor the fingerprint can be different for each
mount point.
This commit is contained in:
Eelco Dolstra 2025-06-06 22:02:45 +02:00
parent f8ef941c04
commit 86785fd9d1
8 changed files with 72 additions and 9 deletions

View file

@ -31,15 +31,16 @@ StorePath fetchToStore(
// a `PosixSourceAccessor` pointing to a store path.
std::optional<fetchers::Cache::Key> cacheKey;
std::optional<std::string> fingerprint;
if (!filter && path.accessor->fingerprint) {
cacheKey = makeFetchToStoreCacheKey(std::string{name}, *path.accessor->fingerprint, method, path.path.abs());
if (!filter && (fingerprint = path.accessor->getFingerprint(path.path))) {
cacheKey = makeFetchToStoreCacheKey(std::string{name}, *fingerprint, method, path.path.abs());
if (auto res = fetchers::getCache()->lookupStorePath(*cacheKey, store)) {
debug("store path cache hit for '%s'", path);
return res->storePath;
}
} else
debug("source path '%s' is uncacheable", path);
debug("source path '%s' is uncacheable (%d, %d)", path, filter, (bool) fingerprint);
Activity act(*logger, lvlChatty, actUnknown,
fmt(mode == FetchMode::DryRun ? "hashing '%s'" : "copying '%s' to the store", path));