Cleanup and simplify toolbox plugin update

This commit is contained in:
Jack Ha 2018-05-14 16:11:44 +02:00
parent 0f0b6a9712
commit 1f088aabc4
3 changed files with 10 additions and 20 deletions

View file

@ -194,11 +194,6 @@ 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 if it is installed
installed_package_info = self.getInstalledPackageInfo(package_info["package_id"])
to_install_package = installed_package_info is None # Install if the package has not been installed

View file

@ -37,10 +37,7 @@ Column
font: UM.Theme.getFont("default_bold")
}
}
onClicked: {
// Must do all stuff in 1 function as the current ToolboxInstalledTile object is going to disappear...
toolbox.update(model.id)
}
onClicked: toolbox.update(model.id)
}
ProgressBar
{

View file

@ -228,9 +228,15 @@ class Toolbox(QObject, Extension):
def _update(self) -> None:
if self._to_update:
plugin_id = self._to_update.pop(0)
Logger.log("d", "Updating package [%s]..." % plugin_id)
self.uninstall(plugin_id)
self.startDownload(self.getRemotePackageURL(plugin_id))
remote_package = self.getRemotePackage(plugin_id)
if remote_package:
download_url = remote_package["download_url"]
Logger.log("d", "Updating package [%s]..." % plugin_id)
self.uninstall(plugin_id)
self.startDownload(download_url)
else:
Logger.log("e", "Could not update package [%s] because there is no remote package info available.", plugin_id)
if self._to_update:
self._application.callLater(self._update)
@ -277,14 +283,6 @@ class Toolbox(QObject, Extension):
break
return remote_package
@pyqtSlot(str, result = str)
def getRemotePackageURL(self, package_id: str) -> str:
remote_package = self.getRemotePackage(package_id)
if remote_package:
return remote_package["download_url"]
else:
return ""
# Checks
# --------------------------------------------------------------------------
@pyqtSlot(str, result = bool)