1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-19 00:39:37 +01:00

fetchToStore(): Improve caching in dry-run mode

In dry-run mode, we don't need to require a valid path.
This commit is contained in:
Eelco Dolstra 2025-06-11 16:13:40 +02:00
parent ac6318c9c5
commit 2f5a545997
3 changed files with 8 additions and 6 deletions

View file

@ -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);
@ -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,
@ -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;
}
};