mirror of
https://github.com/git/git.git
synced 2026-02-15 04:17:44 +00:00
mingw_rmdir: do not prompt for retry when non-empty
in ab1a11be ("mingw_rmdir: set errno=ENOTEMPTY when appropriate"),
a check was added to prevent us from retrying to delete a directory
that is both in use and non-empty.
However, this logic was slightly flawed; since we didn't return
immediately, we end up falling out of the retry-loop, but right into
the prompting-loop.
Fix this by setting errno, and guarding the prompting-loop with an
errno-check.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
This commit is contained in:
@@ -260,6 +260,8 @@ int mingw_rmdir(const char *pathname)
|
|||||||
|
|
||||||
while ((ret = _wrmdir(wpathname)) == -1 && tries < ARRAY_SIZE(delay)) {
|
while ((ret = _wrmdir(wpathname)) == -1 && tries < ARRAY_SIZE(delay)) {
|
||||||
if (!is_file_in_use_error(GetLastError()))
|
if (!is_file_in_use_error(GetLastError()))
|
||||||
|
errno = err_win_to_posix(GetLastError());
|
||||||
|
if (errno != EACCES)
|
||||||
break;
|
break;
|
||||||
if (!is_dir_empty(wpathname)) {
|
if (!is_dir_empty(wpathname)) {
|
||||||
errno = ENOTEMPTY;
|
errno = ENOTEMPTY;
|
||||||
@@ -275,7 +277,7 @@ int mingw_rmdir(const char *pathname)
|
|||||||
Sleep(delay[tries]);
|
Sleep(delay[tries]);
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
while (ret == -1 && is_file_in_use_error(GetLastError()) &&
|
while (ret == -1 && errno == EACCES && is_file_in_use_error(GetLastError()) &&
|
||||||
ask_yes_no_if_possible("Deletion of directory '%s' failed. "
|
ask_yes_no_if_possible("Deletion of directory '%s' failed. "
|
||||||
"Should I try again?", pathname))
|
"Should I try again?", pathname))
|
||||||
ret = _wrmdir(wpathname);
|
ret = _wrmdir(wpathname);
|
||||||
|
|||||||
Reference in New Issue
Block a user