libstore: fix race condition when creating state directories
Running (parallel?) nix in nix can lead to multiple instances trying to create the state directories and failing on the createSymlink step, because the link already exists. `replaceSymlink` is already idempotent, so let's use that. See also: - https://github.com/NixOS/nix/pull/13368 - https://github.com/NixOS/nix/issues/2706 Change-Id: I7fadd0ce3c1ffcebc9d281c00e5b49c12af3d50b
This commit is contained in:
@@ -119,7 +119,7 @@ LocalStore::LocalStore(LocalStoreConfig config)
|
||||
Path gcRootsDir = config_.stateDir + "/gcroots";
|
||||
if (!pathExists(gcRootsDir)) {
|
||||
createDirs(gcRootsDir);
|
||||
createSymlink(profilesDir, gcRootsDir + "/profiles");
|
||||
replaceSymlink(profilesDir, gcRootsDir + "/profiles");
|
||||
}
|
||||
|
||||
for (auto & perUserDir : {profilesDir + "/per-user", gcRootsDir + "/per-user"}) {
|
||||
|
||||
Reference in New Issue
Block a user