From b1658fdf9ae2943a5c08ab8335702c145c0f9a38 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 4 Jan 2022 20:25:30 -0800 Subject: [PATCH] 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 --- eeschema/files-io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index fa1a2c1f71..5c14326f0c 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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() ); }