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

Merge pull request #12486 from NixOS/mergify/bp/2.26-maintenance/pr-12481

resolveLookupPathPath(): Fix caching of negative lookups (backport #12481)
This commit is contained in:
John Ericson 2025-02-17 12:32:58 -05:00 committed by GitHub
commit a13149e03e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -57,7 +57,7 @@ Strings EvalSettings::getDefaultNixPath()
{
Strings res;
auto add = [&](const Path & p, const std::string & s = std::string()) {
if (pathAccessible(p)) {
if (std::filesystem::exists(p)) {
if (s.empty()) {
res.push_back(p);
} else {

View file

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