Fix/Implement update in toolbox

This commit is contained in:
Jack Ha 2018-05-14 16:01:59 +02:00
parent 8718ee34c9
commit 0f0b6a9712
5 changed files with 57 additions and 21 deletions

View file

@ -136,14 +136,14 @@ class CuraPackageManager(QObject):
all_installed_ids = all_installed_ids.union(set(self._bundled_package_dict.keys()))
if self._installed_package_dict.keys():
all_installed_ids = all_installed_ids.union(set(self._installed_package_dict.keys()))
all_installed_ids = all_installed_ids.difference(self._to_remove_package_set)
# If it's going to be installed and to be removed, then the package is being updated and it should be listed.
if self._to_install_package_dict.keys():
all_installed_ids = all_installed_ids.union(set(self._to_install_package_dict.keys()))
all_installed_ids = all_installed_ids.difference(self._to_remove_package_set)
# map of <package_type> -> <package_id> -> <package_info>
installed_packages_dict = {}
for package_id in all_installed_ids:
# Skip required plugins as they should not be tampered with
if package_id in Application.getInstance().getRequiredPlugins():
continue
@ -194,10 +194,10 @@ class CuraPackageManager(QObject):
return
package_id = package_info["package_id"]
# Check the delayed installation and removal lists first
if package_id in self._to_remove_package_set:
self._to_remove_package_set.remove(package_id)
has_changes = True
# # Check the delayed installation and removal lists first
# if package_id in self._to_remove_package_set:
# self._to_remove_package_set.remove(package_id)
# has_changes = True
# Check if it is installed
installed_package_info = self.getInstalledPackageInfo(package_info["package_id"])
@ -235,20 +235,22 @@ class CuraPackageManager(QObject):
self.installedPackagesChanged.emit()
# Schedules the given package to be removed upon the next start.
# \param package_id id of the package
# \param force_add is used when updating. In that case you actually want to uninstall & install
@pyqtSlot(str)
def removePackage(self, package_id: str) -> None:
def removePackage(self, package_id: str, force_add: bool = False) -> None:
# Check the delayed installation and removal lists first
if not self.isPackageInstalled(package_id):
Logger.log("i", "Attempt to remove package [%s] that is not installed, do nothing.", package_id)
return
# Remove from the delayed installation list if present
if package_id in self._to_install_package_dict:
if package_id not in self._to_install_package_dict or force_add:
# Schedule for a delayed removal:
self._to_remove_package_set.add(package_id)
else:
# Remove from the delayed installation list if present
del self._to_install_package_dict[package_id]
# Schedule for a delayed removal:
self._to_remove_package_set.add(package_id)
self._saveManagementData()
self.installedPackagesChanged.emit()