* deletePath() now removes the path from the hash2paths mapping.
This commit is contained in:
parent
ab644ad10b
commit
0b38b43bab
23
src/store.cc
23
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)
|
bool isInPrefix(const string & path, const string & _prefix)
|
||||||
{
|
{
|
||||||
string prefix = canonPath(_prefix + "/");
|
string prefix = canonPath(_prefix + "/");
|
||||||
|
@ -171,6 +190,8 @@ void deleteFromStore(const string & path)
|
||||||
string prefix = nixStore + "/";
|
string prefix = nixStore + "/";
|
||||||
if (string(path, 0, prefix.size()) != prefix)
|
if (string(path, 0, prefix.size()) != prefix)
|
||||||
throw Error(format("path %1% is not in the store") % path);
|
throw Error(format("path %1% is not in the store") % path);
|
||||||
|
|
||||||
|
unregisterPath(path);
|
||||||
|
|
||||||
deletePath(path);
|
deletePath(path);
|
||||||
// delDB(nixDB, dbHash2Paths, hash);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue