about summary refs log tree commit diff
path: root/src/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-08T09·54+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-08T09·54+0000
commit0b38b43bab28dd733e057d42853d57e44ec9a7c9 (patch)
treea4e7c5cecdb168010ffc50cb609702cdb3c57979 /src/store.cc
parentab644ad10b00a5fd23e8d8a705a7a8a8aaf53c57 (diff)
* deletePath() now removes the path from the hash2paths mapping.
Diffstat (limited to 'src/store.cc')
-rw-r--r--src/store.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/store.cc b/src/store.cc
index 2ea7586e91..bb945e037a 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -105,6 +105,25 @@ Hash registerPath(const string & _path, Hash hash)
 }
 
 
+void unregisterPath(const string & _path)
+{
+    string path(canonPath(_path));
+
+    Hash hash = hashPath(path);
+    
+    Strings paths, paths2;
+    queryListDB(nixDB, dbHash2Paths, hash, paths); /* non-existence = ok */
+
+    bool changed = false;
+    for (Strings::iterator it = paths.begin();
+         it != paths.end(); it++)
+        if (*it != path) paths2.push_back(*it); else changed = true;
+
+    if (changed)
+        setListDB(nixDB, dbHash2Paths, hash, paths2);
+}
+
+
 bool isInPrefix(const string & path, const string & _prefix)
 {
     string prefix = canonPath(_prefix + "/");
@@ -171,6 +190,8 @@ void deleteFromStore(const string & path)
     string prefix = nixStore + "/";
     if (string(path, 0, prefix.size()) != prefix)
         throw Error(format("path %1% is not in the store") % path);
+
+    unregisterPath(path);
+
     deletePath(path);
-//     delDB(nixDB, dbHash2Paths, hash);
 }