* Make the garbage collector more resilient to certain consistency
errors: in-use paths now cause a warning, not a fatal error.
This commit is contained in:
parent
8659edc098
commit
8f67b35886
3 changed files with 10 additions and 4 deletions
|
@ -599,9 +599,13 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
printMsg(lvlInfo, format("deleting `%1%'") % *i);
|
||||
|
||||
/* Okay, it's safe to delete. */
|
||||
unsigned long long freed;
|
||||
deleteFromStore(*i, freed);
|
||||
bytesFreed += freed;
|
||||
try {
|
||||
unsigned long long freed;
|
||||
deleteFromStore(*i, freed);
|
||||
bytesFreed += freed;
|
||||
} catch (PathInUse & e) {
|
||||
printMsg(lvlError, format("warning: %1%") % e.msg());
|
||||
}
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
if (fdLock != -1)
|
||||
|
|
|
@ -709,7 +709,7 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
|
|||
for (PathSet::iterator i = referrers.begin();
|
||||
i != referrers.end(); ++i)
|
||||
if (*i != path && isValidPathTxn(txn, *i))
|
||||
throw Error(format("cannot delete path `%1%' because it is in use by path `%2%'") % path % *i);
|
||||
throw PathInUse(format("cannot delete path `%1%' because it is in use by path `%2%'") % path % *i);
|
||||
invalidatePath(txn, path);
|
||||
}
|
||||
txn.commit();
|
||||
|
|
|
@ -138,6 +138,8 @@ Path queryDeriver(const Transaction & txn, const Path & path);
|
|||
/* Delete a value from the nixStore directory. */
|
||||
void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
|
||||
|
||||
MakeError(PathInUse, Error);
|
||||
|
||||
void verifyStore(bool checkContents);
|
||||
|
||||
/* Whether we are in build users mode. */
|
||||
|
|
Loading…
Reference in a new issue