Clean up autosave file handling edge cases

This commit is contained in:
Simon Schaak 2022-11-22 15:21:26 +00:00 committed by Ian McInerney
parent 8b1ffca7fa
commit bd74489b00
1 changed files with 9 additions and 6 deletions

View File

@ -1429,12 +1429,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() );
@ -1462,10 +1467,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() )