Warn when installing PCM local package that is incompatible
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14243
This commit is contained in:
parent
b564d0713c
commit
b2cc4b8310
|
@ -179,7 +179,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 );
|
||||
} );
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,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 )
|
||||
|
|
|
@ -342,6 +342,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;
|
||||
|
@ -378,16 +388,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;
|
||||
|
||||
|
|
|
@ -371,6 +371,7 @@ PCM_TASK_MANAGER::STATUS PCM_TASK_MANAGER::InstallFromFile( wxWindow* aPar
|
|||
}
|
||||
|
||||
PCM_PACKAGE package = metadata.get<PCM_PACKAGE>();
|
||||
PLUGIN_CONTENT_MANAGER::PreparePackage( package );
|
||||
|
||||
if( package.versions.size() != 1 )
|
||||
{
|
||||
|
@ -378,6 +379,15 @@ PCM_TASK_MANAGER::STATUS PCM_TASK_MANAGER::InstallFromFile( wxWindow* aPar
|
|||
return PCM_TASK_MANAGER::STATUS::FAILED;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue