@@ -241,7 +241,17 @@ Goal::Co DerivationGoal::repairClosure()
241241 that produced those outputs. */
242242
243243 /* Get the output closure. */
244- auto outputs = queryDerivationOutputMap ();
244+ auto outputs = [&] {
245+ for (auto * drvStore : {&worker.evalStore , &worker.store })
246+ if (drvStore->isValidPath (drvPath))
247+ return worker.store .queryDerivationOutputMap (drvPath, drvStore);
248+
249+ OutputPathMap res;
250+ for (auto & [name, output] : drv->outputsAndOptPaths (worker.store ))
251+ res.insert_or_assign (name, *output.second );
252+ return res;
253+ }();
254+
245255 StorePathSet outputClosure;
246256 if (auto mPath = get (outputs, wantedOutput)) {
247257 worker.store .computeFSClosure (*mPath , outputClosure);
@@ -304,37 +314,6 @@ Goal::Co DerivationGoal::repairClosure()
304314 co_return done (BuildResult::AlreadyValid, assertPathValidity ());
305315}
306316
307- std::map<std::string, std::optional<StorePath>> DerivationGoal::queryPartialDerivationOutputMap ()
308- {
309- assert (!drv->type ().isImpure ());
310-
311- for (auto * drvStore : {&worker.evalStore , &worker.store })
312- if (drvStore->isValidPath (drvPath))
313- return worker.store .queryPartialDerivationOutputMap (drvPath, drvStore);
314-
315- /* In-memory derivation will naturally fall back on this case, where
316- we do best-effort with static information. */
317- std::map<std::string, std::optional<StorePath>> res;
318- for (auto & [name, output] : drv->outputs )
319- res.insert_or_assign (name, output.path (worker.store , drv->name , name));
320- return res;
321- }
322-
323- OutputPathMap DerivationGoal::queryDerivationOutputMap ()
324- {
325- assert (!drv->type ().isImpure ());
326-
327- for (auto * drvStore : {&worker.evalStore , &worker.store })
328- if (drvStore->isValidPath (drvPath))
329- return worker.store .queryDerivationOutputMap (drvPath, drvStore);
330-
331- // See comment in `DerivationGoal::queryPartialDerivationOutputMap`.
332- OutputPathMap res;
333- for (auto & [name, output] : drv->outputsAndOptPaths (worker.store ))
334- res.insert_or_assign (name, *output.second );
335- return res;
336- }
337-
338317std::pair<bool , SingleDrvOutputs> DerivationGoal::checkPathValidity ()
339318{
340319 if (drv->type ().isImpure ())
@@ -344,7 +323,20 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
344323 StringSet wantedOutputsLeft{wantedOutput};
345324 SingleDrvOutputs validOutputs;
346325
347- for (auto & i : queryPartialDerivationOutputMap ()) {
326+ auto partialDerivationOutputMap = [&] {
327+ for (auto * drvStore : {&worker.evalStore , &worker.store })
328+ if (drvStore->isValidPath (drvPath))
329+ return worker.store .queryPartialDerivationOutputMap (drvPath, drvStore);
330+
331+ /* In-memory derivation will naturally fall back on this case, where
332+ we do best-effort with static information. */
333+ std::map<std::string, std::optional<StorePath>> res;
334+ for (auto & [name, output] : drv->outputs )
335+ res.insert_or_assign (name, output.path (worker.store , drv->name , name));
336+ return res;
337+ }();
338+
339+ for (auto & i : partialDerivationOutputMap) {
348340 auto initialOutput = get (initialOutputs, i.first );
349341 if (!initialOutput)
350342 // this is an invalid output, gets caught with (!wantedOutputsLeft.empty())
0 commit comments