mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Fix downgrade packages to bundled version
CURA-5296
This commit is contained in:
parent
689b88a024
commit
ad131ab30c
2 changed files with 13 additions and 5 deletions
|
@ -111,6 +111,12 @@ class CuraPackageManager(QObject):
|
|||
del self._to_install_package_dict[package_id]
|
||||
self._saveManagementData()
|
||||
|
||||
def getBundledPackageInfo(self, package_id: str) -> Optional[dict]:
|
||||
package_info = None
|
||||
if package_id in self._bundled_package_dict:
|
||||
package_info = self._bundled_package_dict[package_id]["package_info"]
|
||||
return package_info
|
||||
|
||||
# Checks the given package is installed. If so, return a dictionary that contains the package's information.
|
||||
def getInstalledPackageInfo(self, package_id: str) -> Optional[dict]:
|
||||
if package_id in self._to_remove_package_set:
|
||||
|
|
|
@ -318,19 +318,21 @@ class Toolbox(QObject, Extension):
|
|||
remote_version = Version(remote_package["package_version"])
|
||||
return remote_version > local_version
|
||||
|
||||
@pyqtSlot(str, result=bool)
|
||||
@pyqtSlot(str, result = bool)
|
||||
def canDowngrade(self, package_id: str) -> bool:
|
||||
# If the currently installed version is higher than the bundled version (if present), the we can downgrade
|
||||
# this package.
|
||||
local_package = self._package_manager.getInstalledPackageInfo(package_id)
|
||||
if local_package is None:
|
||||
return False
|
||||
|
||||
remote_package = self.getRemotePackage(package_id)
|
||||
if remote_package is None:
|
||||
bundled_package = self._package_manager.getBundledPackageInfo(package_id)
|
||||
if bundled_package is None:
|
||||
return False
|
||||
|
||||
local_version = Version(local_package["package_version"])
|
||||
remote_version = Version(remote_package["package_version"])
|
||||
return remote_version < local_version
|
||||
bundled_version = Version(bundled_package["package_version"])
|
||||
return bundled_version < local_version
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isInstalled(self, package_id: str) -> bool:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue