mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 15:32:43 +01:00
* Reject a build if there is a cycle among the outputs. This is
necessary because existing code assumes that the references graph is acyclic.
This commit is contained in:
parent
254b3399ba
commit
b1004f40f7
4 changed files with 24 additions and 9 deletions
|
|
@ -966,12 +966,14 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
|||
while (1) {
|
||||
try {
|
||||
SQLiteTxn txn(db);
|
||||
PathSet paths;
|
||||
|
||||
foreach (ValidPathInfos::const_iterator, i, infos) {
|
||||
assert(i->hash.type == htSHA256);
|
||||
/* !!! Maybe the registration info should be updated if the
|
||||
path is already valid. */
|
||||
if (!isValidPath(i->path)) addValidPath(*i);
|
||||
paths.insert(i->path);
|
||||
}
|
||||
|
||||
foreach (ValidPathInfos::const_iterator, i, infos) {
|
||||
|
|
@ -980,6 +982,12 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
|||
addReference(referrer, queryValidPathId(*j));
|
||||
}
|
||||
|
||||
/* 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
|
||||
has multiple outputs. */
|
||||
topoSortPaths(*this, paths);
|
||||
|
||||
txn.commit();
|
||||
break;
|
||||
} catch (SQLiteBusy & e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue