Add final so the management JSON is always saved

CURA-5035
This commit is contained in:
Lipu Fei 2018-05-02 12:57:24 +02:00
parent 09af97634d
commit 49649e3d4a

View file

@ -183,11 +183,12 @@ class CuraPackageManager(QObject):
# Schedules the given package file to be installed upon the next start.
@pyqtSlot(str)
def installPackage(self, filename: str) -> None:
has_changes = False
try:
# Get package information
package_info = self.getPackageInfo(filename)
package_id = package_info["package_id"]
has_changes = False
# 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)
@ -206,6 +207,8 @@ class CuraPackageManager(QObject):
to_install_package = True
if to_install_package:
# Need to use the lock file to prevent concurrent I/O issues.
with self._container_registry.lockFile():
Logger.log("i", "Package [%s] version [%s] is scheduled to be installed.",
package_id, package_info["package_version"])
# Copy the file to cache dir so we don't need to rely on the original file to be present
@ -219,7 +222,9 @@ class CuraPackageManager(QObject):
self._to_install_package_dict[package_id] = {"package_info": package_info,
"filename": target_file_path}
has_changes = True
except:
Logger.logException("c", "Failed to install package file '%s'", filename)
finally:
self._saveManagementData()
if has_changes:
self.installedPackagesChanged.emit()