Windows: Retry failed rename patch applied.

On Windows, rename can fail for example due to a virus checker.  This patch retries renaming the file.
(see bug #1266 and http://reviews.llvm.org/D13647#eeab044e)

Audacity/win/wxWidgets_Additions/fix_rename.diff
This commit is contained in:
James Crook 2016-12-29 17:27:06 +00:00 committed by Leland Lucius
parent 5d526180f3
commit 19230f711f

View File

@ -1116,7 +1116,8 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
bool
wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
{
if ( !overwrite && wxFileExists(file2) )
bool exists = wxFileExists(file2);
if ( !overwrite && exists )
{
wxLogSysError
(
@ -1128,8 +1129,21 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
}
// Normal system call
if ( wxRename (file1, file2) == 0 )
return true;
//
// For explanation, see: (warning...based mostly on observed behavior)
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1266
// https://github.com/audacity/audacity/pull/94
unsigned long doserrno = 0;
for (int i = 0; i < 2000; i++)
{
if ( wxRename (file1, file2) == 0 )
return true;
unsigned long doserrno;
_get_doserrno(&doserrno);
if (doserrno != ERROR_ACCESS_DENIED && (doserrno != ERROR_ALREADY_EXISTS || exists))
break;
wxMilliSleep(1);
}
// Try to copy
if (wxCopyFile(file1, file2, overwrite)) {