diff --git a/compat/mingw.c b/compat/mingw.c index fbbbe86f8e21c4..8df2e9740d7b42 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2590,6 +2590,13 @@ int mingw_rename(const char *pold, const char *pnew) return 0; gle = GetLastError(); + if (gle == ERROR_ACCESS_DENIED && is_inside_windows_container()) { + /* Fall back to copy to destination & remove source */ + if (CopyFileW(wpold, wpnew, FALSE) && !mingw_unlink(pold)) + return 0; + gle = GetLastError(); + } + /* revert file attributes on failure */ if (attrs != INVALID_FILE_ATTRIBUTES) SetFileAttributesW(wpnew, attrs);