mirror of
https://github.com/NixOS/nix.git
synced 2025-11-22 10:19:36 +01:00
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.
Resolves #2706
(cherry picked from commit d64c922164)
This commit is contained in:
parent
0877680b08
commit
229e97195a
1 changed files with 1 additions and 1 deletions
|
|
@ -130,7 +130,7 @@ LocalStore::LocalStore(ref<const Config> config)
|
||||||
Path gcRootsDir = config->stateDir + "/gcroots";
|
Path gcRootsDir = config->stateDir + "/gcroots";
|
||||||
if (!pathExists(gcRootsDir)) {
|
if (!pathExists(gcRootsDir)) {
|
||||||
createDirs(gcRootsDir);
|
createDirs(gcRootsDir);
|
||||||
createSymlink(profilesDir, gcRootsDir + "/profiles");
|
replaceSymlink(profilesDir, gcRootsDir + "/profiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & perUserDir : {profilesDir + "/per-user", gcRootsDir + "/per-user"}) {
|
for (auto & perUserDir : {profilesDir + "/per-user", gcRootsDir + "/per-user"}) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue