7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 11:01:41 +00:00

Fix loading old (2007) symbol cache library files.

This commit is contained in:
Alex Shvartzkop 2025-02-12 14:13:50 +03:00
parent b7293f1d77
commit f5186da1e5
2 changed files with 33 additions and 5 deletions

View File

@ -471,6 +471,27 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter )
srcFileName.GetFullPath() );
}
// Back up the old (2007) cache library.
srcFileName.SetPath( Prj().GetProjectPath() );
srcFileName.SetName( Prj().GetProjectName() + wxS( ".cache" ) );
srcFileName.SetExt( FILEEXT::LegacySymbolLibFileExtension );
destFileName = srcFileName;
destFileName.SetName( destFileName.GetName() + timeStamp );
destFileName.AppendDir( backupFolder );
aReporter.Report( wxString::Format( _( "Backing up file '%s' to '%s'." ),
srcFileName.GetFullPath(),
destFileName.GetFullPath() ),
RPT_SEVERITY_INFO );
if( srcFileName.Exists()
&& !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) )
{
errorMsg += wxString::Format( _( "Failed to back up file '%s'.\n" ),
srcFileName.GetFullPath() );
}
// Back up the rescue symbol library if it exists.
srcFileName.SetName( Prj().GetProjectName() + wxS( "-rescue" ) );
destFileName.SetName( srcFileName.GetName() + timeStamp );

View File

@ -484,13 +484,20 @@ void SYMBOL_LIBS::SetLibNamesAndPaths( PROJECT* aProject, const wxString& aPaths
const wxString SYMBOL_LIBS::CacheName( const wxString& aFullProjectFilename )
{
wxFileName name = aFullProjectFilename;
wxFileName filename( aFullProjectFilename );
wxString name = filename.GetName();
name.SetName( name.GetName() + "-cache" );
name.SetExt( FILEEXT::LegacySymbolLibFileExtension );
filename.SetName( name + "-cache" );
filename.SetExt( FILEEXT::LegacySymbolLibFileExtension );
if( name.FileExists() )
return name.GetFullPath();
if( filename.FileExists() )
return filename.GetFullPath();
// Try the old (2007) cache name
filename.SetName( name + ".cache" );
if( filename.FileExists() )
return filename.GetFullPath();
return wxEmptyString;
}