mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
GC: Don't delete own temproots file
Since file locks are per-process rather than per-file-descriptor, the garbage collector would always acquire a lock on its own temproots file and conclude that it's stale.
This commit is contained in:
parent
8215b75d36
commit
b932ea58ec
3 changed files with 34 additions and 34 deletions
|
|
@ -51,6 +51,8 @@ LocalStore::LocalStore(const Params & params)
|
|||
, reservedPath(dbDir + "/reserved")
|
||||
, schemaPath(dbDir + "/schema")
|
||||
, trashDir(realStoreDir + "/trash")
|
||||
, tempRootsDir(stateDir + "/temproots")
|
||||
, fnTempRoots(fmt("%s/%d", tempRootsDir, getpid()))
|
||||
, publicKeys(getDefaultPublicKeys())
|
||||
{
|
||||
auto state(_state.lock());
|
||||
|
|
@ -61,7 +63,7 @@ LocalStore::LocalStore(const Params & params)
|
|||
createDirs(linksDir);
|
||||
Path profilesDir = stateDir + "/profiles";
|
||||
createDirs(profilesDir);
|
||||
createDirs(stateDir + "/temproots");
|
||||
createDirs(tempRootsDir);
|
||||
createDirs(dbDir);
|
||||
Path gcRootsDir = stateDir + "/gcroots";
|
||||
if (!pathExists(gcRootsDir)) {
|
||||
|
|
@ -242,12 +244,12 @@ LocalStore::LocalStore(const Params & params)
|
|||
|
||||
LocalStore::~LocalStore()
|
||||
{
|
||||
auto state(_state.lock());
|
||||
|
||||
try {
|
||||
auto state(_state.lock());
|
||||
if (state->fdTempRoots) {
|
||||
state->fdTempRoots = -1;
|
||||
unlink(state->fnTempRoots.c_str());
|
||||
unlink(fnTempRoots.c_str());
|
||||
}
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue