Commit 1bcdaba2bc87d12cf7666ee1b2c238ccc92024f2

Carson Howard 2017-07-18T14:47:28

fixed win32 p_unlink retry sleep issue Fixed an issue where the retry logic on p_unlink sleeps before it tries setting a file to write mode causing unnecessary slowdown.

diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index e4fe414..32fafa8 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -243,6 +243,11 @@ GIT_INLINE(int) unlink_once(const wchar_t *path)
 	if (DeleteFileW(path))
 		return 0;
 
+	set_errno();
+
+	if (errno == EACCES && ensure_writable(path) == 0 && DeleteFileW(path))
+		return 0;
+
 	if (last_error_retryable())
 		return GIT_RETRY;
 
@@ -257,7 +262,7 @@ int p_unlink(const char *path)
 	if (git_win32_path_from_utf8(wpath, path) < 0)
 		return -1;
 
-	do_with_retries(unlink_once(wpath), ensure_writable(wpath));
+	do_with_retries(unlink_once(wpath), 0);
 }
 
 int p_fsync(int fd)