From 388271e8ec6f5057bc8d39865fcc280e044b2844 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 6 Nov 2024 23:52:48 +0100 Subject: [PATCH] initRepoAtomically: Catch directory_not_empty --- src/libfetchers/git-utils.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 95ee330893a..74e68fe1281 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -217,8 +217,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); }