Don't assume a total output map in two places in build.cc

Thanks @regnat for catching one of them. The other follows for many of
the same reasons. I'm find fixing others on a need-to-fix basis,
provided their are no regressions.
This commit is contained in:
John Ericson 2020-08-11 23:07:50 +00:00
parent 4c6aac8fdf
commit 2de201254e

View file

@ -1389,9 +1389,10 @@ void DerivationGoal::repairClosure()
std::map<StorePath, StorePath> outputsToDrv;
for (auto & i : inputClosure)
if (i.isDerivation()) {
auto depOutputs = worker.store.queryDerivationOutputMapAssumeTotal(i);
auto depOutputs = worker.store.queryDerivationOutputMap(i);
for (auto & j : depOutputs)
outputsToDrv.insert_or_assign(j.second, i);
if (j.second)
outputsToDrv.insert_or_assign(*j.second, i);
}
/* Check each path (slow!). */
@ -1459,11 +1460,16 @@ void DerivationGoal::inputsRealised()
`i' as input paths. Only add the closures of output paths
that are specified as inputs. */
assert(worker.store.isValidPath(drvPath));
auto outputs = worker.store.queryDerivationOutputMapAssumeTotal(depDrvPath);
auto outputs = worker.store.queryDerivationOutputMap(depDrvPath);
for (auto & j : wantedDepOutputs) {
if (outputs.count(j) > 0)
worker.store.computeFSClosure(outputs.at(j), inputPaths);
else
if (outputs.count(j) > 0) {
auto optRealizedInput = outputs.at(j);
if (!optRealizedInput)
throw Error(
"derivation '%s' requires output '%s' from input derivation '%s', which is supposedly realized already, yet we still don't know what path corresponds to that output.",
worker.store.printStorePath(drvPath), j, worker.store.printStorePath(drvPath));
worker.store.computeFSClosure(*optRealizedInput, inputPaths);
} else
throw Error(
"derivation '%s' requires non-existent output '%s' from input derivation '%s'",
worker.store.printStorePath(drvPath), j, worker.store.printStorePath(drvPath));