mirror of
https://github.com/NixOS/nix.git
synced 2025-12-16 05:51:05 +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
bab4e58a5e
commit
e52fe2cab4
1 changed files with 1 additions and 1 deletions
|
|
@ -126,7 +126,7 @@ LocalStore::LocalStore(std::string_view scheme, PathView path, const Params & pa
|
||||||
Path gcRootsDir = stateDir + "/gcroots";
|
Path gcRootsDir = 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