Don't rename existing schematic file

We should never leave a situation where the schematic file may no longer
exist (if the first rename succeeds and the second fails).  So, make a
backup copy of the original schematic file and then attempt to rename
the autosave over the first file.  In this case, if either attempt
fails, we do not lose the original file

Fixes https://gitlab.com/kicad/code/kicad/issues/10074

Fixes https://gitlab.com/kicad/code/kicad/issues/10256

Fixes https://gitlab.com/kicad/code/kicad/issues/10219

(cherry picked from commit b1658fdf9a)
This commit is contained in:
Seth Hillbrand 2022-01-04 20:25:30 -08:00
parent cc5003a919
commit b0fddef9b4
1 changed files with 1 additions and 1 deletions

View File

@ -1417,7 +1417,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
// Attempt to back up the last schematic file before overwriting it with the auto
// save file.
if( !wxRenameFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) )
if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) )
{
unrecoveredFiles.Add( recoveredFn.GetFullPath() );
}