Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/libfetchers/cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ struct CacheImpl : Cache

std::optional<ResultWithStorePath> lookupStorePath(
Key key,
Store & store) override
Store & store,
bool allowInvalid) override
{
key.second.insert_or_assign("store", store.storeDir);

Expand All @@ -135,7 +136,7 @@ struct CacheImpl : Cache
ResultWithStorePath res2(*res, StorePath(storePathS));

store.addTempRoot(res2.storePath);
if (!store.isValidPath(res2.storePath)) {
if (!allowInvalid && !store.isValidPath(res2.storePath)) {
// FIXME: we could try to substitute 'storePath'.
debug("ignoring disappeared cache entry '%s:%s' -> '%s'",
key.first,
Expand All @@ -157,7 +158,7 @@ struct CacheImpl : Cache
Key key,
Store & store) override
{
auto res = lookupStorePath(std::move(key), store);
auto res = lookupStorePath(std::move(key), store, false);
return res && !res->expired ? res : std::nullopt;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/fetch-to-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ StorePath fetchToStore(

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)) {
if (auto res = fetchers::getCache()->lookupStorePath(*cacheKey, store, mode == FetchMode::DryRun)) {
debug("store path cache hit for '%s'", path);
return res->storePath;
}
Expand Down
5 changes: 3 additions & 2 deletions src/libfetchers/include/nix/fetchers/cache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ struct Cache

/**
* Look up a store path in the cache. The returned store path will
* be valid, but it may be expired.
* be valid (unless `allowInvalid` is true), but it may be expired.
*/
virtual std::optional<ResultWithStorePath> lookupStorePath(
Key key,
Store & store) = 0;
Store & store,
bool allowInvalid = false) = 0;

/**
* Look up a store path in the cache. Return nothing if its TTL
Expand Down