From 0b38b43bab28dd733e057d42853d57e44ec9a7c9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Jul 2003 09:54:47 +0000 Subject: * deletePath() now removes the path from the hash2paths mapping. --- src/store.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/store.cc b/src/store.cc index 2ea7586e91e4..bb945e037ad3 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); } -- cgit 1.4.1