diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 71ea1fd464..0d3a57899d 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -1421,12 +1421,17 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName ) " Auto save file: '%s'" ), recoveredFn.GetFullPath(), backupFn.GetFullPath(), fn ); - // Attempt to back up the last schematic file before overwriting it with the auto - // save file. - if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) ) + if( !wxFileExists( fn ) ) { unrecoveredFiles.Add( recoveredFn.GetFullPath() ); } + // Attempt to back up the last schematic file before overwriting it with the auto + // save file. + else if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) ) + { + unrecoveredFiles.Add( recoveredFn.GetFullPath() ); + } + // Attempt to replace last saved file with auto save file else if( !wxRenameFile( fn, recoveredFn.GetFullPath() ) ) { unrecoveredFiles.Add( recoveredFn.GetFullPath() ); @@ -1454,10 +1459,8 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName ) { wxLogTrace( traceAutoSave, wxT( "Removing auto save file " ) + fn ); - if( !wxRemoveFile( fn ) ) - { + if( wxFileExists( fn ) && !wxRemoveFile( fn ) ) unremovedFiles.Add( fn ); - } } if( !unremovedFiles.IsEmpty() )