Don't remove a read-only settings file
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12844
This commit is contained in:
parent
8832c5239e
commit
3a15fa5e0f
|
@ -183,12 +183,14 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
||||||
// already loaded above
|
// already loaded above
|
||||||
if( !MigrateFromLegacy( cfg.get() ) )
|
if( !MigrateFromLegacy( cfg.get() ) )
|
||||||
{
|
{
|
||||||
|
success = false;
|
||||||
wxLogTrace( traceSettings,
|
wxLogTrace( traceSettings,
|
||||||
wxT( "%s: migrated; not all settings were found in legacy file" ),
|
wxT( "%s: migrated; not all settings were found in legacy file" ),
|
||||||
GetFullFilename() );
|
GetFullFilename() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
success = true;
|
||||||
wxLogTrace( traceSettings, wxT( "%s: migrated from legacy format" ), GetFullFilename() );
|
wxLogTrace( traceSettings, wxT( "%s: migrated from legacy format" ), GetFullFilename() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,6 +312,7 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
||||||
}
|
}
|
||||||
catch( nlohmann::json::parse_error& error )
|
catch( nlohmann::json::parse_error& error )
|
||||||
{
|
{
|
||||||
|
success = false;
|
||||||
wxLogTrace( traceSettings, wxT( "Json parse error reading %s: %s" ),
|
wxLogTrace( traceSettings, wxT( "Json parse error reading %s: %s" ),
|
||||||
path.GetFullPath(), error.what() );
|
path.GetFullPath(), error.what() );
|
||||||
wxLogTrace( traceSettings, wxT( "Attempting migration in case file is in legacy format" ) );
|
wxLogTrace( traceSettings, wxT( "Attempting migration in case file is in legacy format" ) );
|
||||||
|
@ -327,7 +330,7 @@ bool JSON_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
||||||
wxLogTrace( traceSettings, wxT( "Loaded <%s> with schema %d" ), GetFullFilename(), m_schemaVersion );
|
wxLogTrace( traceSettings, wxT( "Loaded <%s> with schema %d" ), GetFullFilename(), m_schemaVersion );
|
||||||
|
|
||||||
// If we migrated, clean up the legacy file (with no extension)
|
// If we migrated, clean up the legacy file (with no extension)
|
||||||
if( legacy_migrated || migrated )
|
if( m_writeFile && ( legacy_migrated || migrated ) )
|
||||||
{
|
{
|
||||||
if( legacy_migrated && m_deleteLegacyAfterMigration && !wxRemoveFile( path.GetFullPath() ) )
|
if( legacy_migrated && m_deleteLegacyAfterMigration && !wxRemoveFile( path.GetFullPath() ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue