Unify and correct Autosave functions
Autosave was not working correctly, partly due to different
implementations in eeschema and pcbnew and partly due to a mistaken
refactor at some point during v5 development. This unifies the expected
autosave prefix to _autosave- for both pcbnew and eeschema. It also
unifies the expected suffix for the backup files to -bak.
Fixes: lp:1820433
* https://bugs.launchpad.net/kicad/+bug/1820433
(cherry picked from commit 078320e2fb)
This commit is contained in:
@@ -582,16 +582,14 @@ bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
|
||||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
|
||||
const wxString& aBackupFileExtension )
|
||||
void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
|
||||
{
|
||||
wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
|
||||
wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
|
||||
|
||||
wxFileName autoSaveFileName = aFileName;
|
||||
|
||||
// Check for auto save file.
|
||||
autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
|
||||
autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() );
|
||||
|
||||
wxLogTrace( traceAutoSave,
|
||||
wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
|
||||
@@ -615,18 +613,14 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
|
||||
{
|
||||
// Get the backup file name.
|
||||
wxFileName backupFileName = aFileName;
|
||||
backupFileName.SetExt( aBackupFileExtension );
|
||||
backupFileName.SetExt( aFileName.GetExt() + GetBackupSuffix() );
|
||||
|
||||
// If an old backup file exists, delete it. If an old copy of the file exists, rename
|
||||
// it to the backup file name
|
||||
if( aFileName.FileExists() )
|
||||
{
|
||||
// Remove the old file backup file.
|
||||
if( backupFileName.FileExists() )
|
||||
wxRemoveFile( backupFileName.GetFullPath() );
|
||||
|
||||
// Rename the old file to the backup file name.
|
||||
if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
|
||||
if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath(), true ) )
|
||||
{
|
||||
msg.Printf( _( "Could not create backup file \"%s\"" ),
|
||||
GetChars( backupFileName.GetFullPath() ) );
|
||||
|
||||
Reference in New Issue
Block a user