From c505702265833a762d681952bcc72562d64a242e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 27 Jan 2005 15:21:29 +0000 Subject: * Fix and simplify the garbage collector (it's still not concurrent, though). In particular it's now much easier to register a GC root. Just place a symlink to whatever store path it is that you want to keep in /nix/var/nix/gcroots. --- src/libstore/store.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/libstore/store.cc') diff --git a/src/libstore/store.cc b/src/libstore/store.cc index f5e7d2aa5..30573992c 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -363,9 +363,9 @@ void registerSubstitute(const Transaction & txn, } -Substitutes querySubstitutes(const Path & srcPath) +Substitutes querySubstitutes(const Transaction & txn, const Path & srcPath) { - return readSubstitutes(noTxn, srcPath); + return readSubstitutes(txn, srcPath); } @@ -411,6 +411,13 @@ static void invalidatePath(const Path & path, Transaction & txn) debug(format("unregistering path `%1%'") % path); nixDB.delPair(txn, dbValidPaths, path); + + /* Clear the `references' entry for this path, as well as the + inverse `referers' entries; but only if there are no + substitutes for this path. This maintains the cleanup + invariant. */ + if (querySubstitutes(txn, path).size() == 0) + setReferences(txn, path, PathSet()); } -- cgit v1.2.3