mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 05:00:58 +01:00
* 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.
This commit is contained in:
parent
33c5d23b81
commit
252c9c91ab
3 changed files with 83 additions and 38 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue