diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-30T14·47+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-12-30T14·47+0000 |
commit | b1004f40f7e4dd02feec2d0cb26bd6c95dd66dde (patch) | |
tree | 185519967aa2ef3c9a03309d9838d5418eb1d2a3 /src/libstore/local-store.cc | |
parent | 254b3399ba3d7cf161fa54f9cf6cdc65c17164fb (diff) |
* Reject a build if there is a cycle among the outputs. This is
necessary because existing code assumes that the references graph is acyclic.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 29817df9d6e8..771776f6a2c7 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -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) { |