mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
initRepoAtomically: Catch directory_not_empty
(cherry picked from commit 388271e8ec
)
This commit is contained in:
parent
960c288fa0
commit
c3e2419e73
1 changed files with 5 additions and 1 deletions
|
@ -171,8 +171,12 @@ static void initRepoAtomically(std::filesystem::path &path, bool bare) {
|
||||||
try {
|
try {
|
||||||
std::filesystem::rename(tmpDir, path);
|
std::filesystem::rename(tmpDir, path);
|
||||||
} catch (std::filesystem::filesystem_error & e) {
|
} catch (std::filesystem::filesystem_error & e) {
|
||||||
if (e.code() == std::errc::file_exists) // Someone might race us to create the repository.
|
// Someone may race us to create the repository.
|
||||||
|
if (e.code() == std::errc::file_exists
|
||||||
|
// `path` may be attempted to be deleted by s::f::rename, in which case the code is:
|
||||||
|
|| e.code() == std::errc::directory_not_empty) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw SysError("moving temporary git repository from %s to %s", tmpDir, path);
|
throw SysError("moving temporary git repository from %s to %s", tmpDir, path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue