about summary refs log tree commit diff
path: root/src/libstore/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-31T14·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-31T14·00+0000
commit252c9c91abe146e9c6b16d795c6566df4adafe56 (patch)
tree568655fd2824cea135ad8a5a7a87a2662570ae95 /src/libstore/store.cc
parent33c5d23b814e16687808d5f2d79798fef7dc2a8a (diff)
* Topologically sort paths under the references relation to ensure
  that they are deleted in an order that maintains the closure
  invariant.
* Presence of a path in a temporary roots file does not imply that all
  paths in its closure are also present, so add the closure.

Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r--src/libstore/store.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 7c0faaf6c4d9..396835013f05 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -311,10 +311,9 @@ void queryReferences(const Path & storePath, PathSet & references)
 
 void queryReferers(const Path & storePath, PathSet & referers)
 {
-    Paths referers2;
     if (!isRealisablePath(noTxn, storePath))
         throw Error(format("path `%1%' is not valid") % storePath);
-    nixDB.queryStrings(noTxn, dbReferers, storePath, referers2);
+    PathSet referers2 = getReferers(noTxn, storePath);
     referers.insert(referers2.begin(), referers2.end());
 }
 
@@ -427,6 +426,8 @@ void registerValidPath(const Transaction & txn,
 }
 
 
+/* Invalidate a path.  The caller is responsible for checking that
+   there are no referers. */
 static void invalidatePath(const Path & path, Transaction & txn)
 {
     debug(format("unregistering path `%1%'") % path);
@@ -551,8 +552,11 @@ void deleteFromStore(const Path & _path)
     assertStorePath(path);
 
     Transaction txn(nixDB);
-    if (isValidPathTxn(txn, path))
+    if (isValidPathTxn(txn, path)) {
+        if (getReferers(txn, path).size() > 0)
+            throw Error(format("cannot delete path `%1%' because it is in use") % path);
         invalidatePath(path, txn);
+    }
     txn.commit();
 
     deletePath(path);