Fix assertion failure in ‘nix-store --load-db’

Namely:

  nix-store: derivations.cc:242: nix::Hash nix::hashDerivationModulo(nix::StoreAPI&, nix::Derivation): Assertion `store.isValidPath(i->first)' failed.

This happened because of the derivation output correctness check being
applied before the references of a derivation are valid.
This commit is contained in:
Eelco Dolstra 2014-02-03 22:36:07 +01:00
parent 73a775f3b7
commit d210cdc435
1 changed files with 12 additions and 1 deletions

View File

@ -1274,7 +1274,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
if (isValidPath_(i->path))
updatePathInfo(*i);
else
addValidPath(*i);
addValidPath(*i, false);
paths.insert(i->path);
}
@ -1284,6 +1284,17 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
addReference(referrer, queryValidPathId(*j));
}
/* Check that the derivation outputs are correct. We can't do
this in addValidPath() above, because the references might
not be valid yet. */
foreach (ValidPathInfos::const_iterator, i, infos)
if (isDerivation(i->path)) {
// FIXME: inefficient; we already loaded the
// derivation in addValidPath().
Derivation drv = parseDerivation(readFile(i->path));
checkDerivationOutputs(i->path, drv);
}
/* Do a topological sort of the paths. This will throw an
error if a cycle is detected and roll back the
transaction. Cycles can only occur when a derivation