Merge pull request #11823 from NixOS/mergify/bp/2.24-maintenance/pr-11821

initRepoAtomically: Catch directory_not_empty (backport #11821)
This commit is contained in:
Jörg Thalheim 2024-11-07 08:03:52 +01:00 committed by GitHub
commit 6e095ddef9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -171,8 +171,12 @@ static void initRepoAtomically(std::filesystem::path &path, bool bare) {
try {
std::filesystem::rename(tmpDir, path);
} 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;
}
else
throw SysError("moving temporary git repository from %s to %s", tmpDir, path);
}