Warn when installing PCM local package that is incompatible

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14243

(Cherry-picked from b2cc4b8310)
This commit is contained in:
Ian McInerney 2023-11-12 20:42:45 +00:00
parent 60d23b14e7
commit 4cb9edd9f0
3 changed files with 24 additions and 14 deletions

View File

@ -215,7 +215,7 @@ PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER(
std::for_each( m_installed.begin(), m_installed.end(),
[&]( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& entry )
{
preparePackage( entry.second.package );
PreparePackage( entry.second.package );
} );
}
@ -478,7 +478,7 @@ const bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryI
for( size_t i = 0; i < saved_repo.package_list.size(); i++ )
{
preparePackage( saved_repo.package_list[i] );
PreparePackage( saved_repo.package_list[i] );
saved_repo.package_map[saved_repo.package_list[i].identifier] = i;
}
@ -508,7 +508,7 @@ const bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryI
for( size_t i = 0; i < current_repo.package_list.size(); i++ )
{
preparePackage( current_repo.package_list[i] );
PreparePackage( current_repo.package_list[i] );
current_repo.package_map[current_repo.package_list[i].identifier] = i;
}
@ -648,7 +648,7 @@ void PLUGIN_CONTENT_MANAGER::updateInstalledPackagesMetadata( const wxString& aR
}
void PLUGIN_CONTENT_MANAGER::preparePackage( PCM_PACKAGE& aPackage )
void PLUGIN_CONTENT_MANAGER::PreparePackage( PCM_PACKAGE& aPackage )
{
// Parse package version strings
for( PACKAGE_VERSION& ver : aPackage.versions )

View File

@ -341,6 +341,16 @@ public:
*/
void ReadEnvVar();
/**
* @brief Parses version strings and calculates compatibility
*
* This should be called after loading package metadata from repository or from
* installation entries
*
* @param aPackage package metadata object
*/
static void PreparePackage( PCM_PACKAGE& aPackage );
private:
///< Default download limit of 10 Mb to not use too much memory
static constexpr size_t DEFAULT_DOWNLOAD_MEM_LIMIT = 10 * 1024 * 1024;
@ -377,16 +387,6 @@ private:
*/
void updateInstalledPackagesMetadata( const wxString& aRepositoryId );
/**
* @brief Parses version strings and calculates compatibility
*
* This should be called after loading package metadata from repository or from
* installation entries
*
* @param aPackage package metadata object
*/
static void preparePackage( PCM_PACKAGE& aPackage );
///< Returns current UTC timestamp
time_t getCurrentTimestamp() const;

View File

@ -371,6 +371,7 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile
}
PCM_PACKAGE package = metadata.get<PCM_PACKAGE>();
PLUGIN_CONTENT_MANAGER::PreparePackage( package );
if( package.versions.size() != 1 )
{
@ -378,6 +379,15 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile
return;
}
if( !package.versions[0].compatible
&& wxMessageBox( _( "This package version is incompatible with your kicad version or "
"platform. Are you sure you want to install it anyway?" ),
_( "Install package" ), wxICON_EXCLAMATION | wxYES_NO, aParent )
== wxNO )
{
return PCM_TASK_MANAGER::STATUS::FAILED;
}
bool isUpdate = false;
// wxRegEx is not CopyConstructible hence the weird choice of forward_list
std::forward_list<wxRegEx> keep_on_update;