Fix downgrade packages to bundled version

CURA-5296
This commit is contained in:
Lipu Fei 2018-05-28 11:18:22 +02:00
parent 689b88a024
commit ad131ab30c
2 changed files with 13 additions and 5 deletions

View file

@ -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: