1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

resolveLookupPathPath(): Fix caching of negative lookups

This avoids spamming in case the missing search path entry does not
exist (#12480).
This commit is contained in:
Eelco Dolstra 2025-02-17 11:50:54 +01:00
parent 8ac49ea5de
commit df08e1e204

View file

@ -3070,8 +3070,11 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
auto i = lookupPathResolved.find(value); auto i = lookupPathResolved.find(value);
if (i != lookupPathResolved.end()) return i->second; if (i != lookupPathResolved.end()) return i->second;
auto finish = [&](SourcePath res) { auto finish = [&](std::optional<SourcePath> res) {
debug("resolved search path element '%s' to '%s'", value, res); if (res)
debug("resolved search path element '%s' to '%s'", value, *res);
else
debug("failed to resolve search path element '%s'", value);
lookupPathResolved.emplace(value, res); lookupPathResolved.emplace(value, res);
return res; return res;
}; };
@ -3123,8 +3126,7 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
} }
} }
debug("failed to resolve search path element '%s'", value); return finish(std::nullopt);
return std::nullopt;
} }