aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/misc.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2021-06-11 09:24:24 +0200
committerregnat <rg@regnat.ovh>2021-06-11 09:26:49 +0200
commit7ac038fa4b83aaeff0b4dcf97b912cd7fd5f0ef6 (patch)
treed5dbdef97cbd87bb83da52e185f0a25b3dbeeb4c /src/libstore/misc.cc
parent8e6ee1b9e924fbbbeb5594eb89e7a570f36ab6e1 (diff)
Make `computeFSClosure` ca-aware
Fix #4820 by preventing nix-collect garbage from crashing if `keep-outputs` or `keep-derivations` is true
Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r--src/libstore/misc.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index bc5fd968c..3e54bfd8f 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -29,9 +29,9 @@ void Store::computeFSClosure(const StorePathSet & startPaths,
res.insert(i);
if (includeDerivers && path.isDerivation())
- for (auto& i : queryDerivationOutputs(path))
- if (isValidPath(i) && queryPathInfo(i)->deriver == path)
- res.insert(i);
+ for (auto& [_, maybeOutPath] : queryPartialDerivationOutputMap(path))
+ if (maybeOutPath && isValidPath(*maybeOutPath) && queryPathInfo(*maybeOutPath)->deriver == path)
+ res.insert(*maybeOutPath);
return res;
};
else
@@ -44,9 +44,9 @@ void Store::computeFSClosure(const StorePathSet & startPaths,
res.insert(ref);
if (includeOutputs && path.isDerivation())
- for (auto& i : queryDerivationOutputs(path))
- if (isValidPath(i))
- res.insert(i);
+ for (auto& [_, maybeOutPath] : queryPartialDerivationOutputMap(path))
+ if (maybeOutPath && isValidPath(*maybeOutPath))
+ res.insert(*maybeOutPath);
if (includeDerivers && info->deriver && isValidPath(*info->deriver))
res.insert(*info->deriver);