From 4fe199ccc7933f437e503212a25dfb08118a4476 Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Thu, 24 Jun 2021 17:26:57 +0200 Subject: [PATCH] Ignore files-in-use while restoring a backup Sometimes, while a backup is being restore, one of the files in the current config folder may be still in use. This means that once the backup tries to replace this file with the one in the backup, the entire backup restoration fails and half the configuration folder has been messed up. To prevent that, we decided to ignore files that are currently in use while restoring a backup. This _may_ lead to a slightly wrong configuration (e.g. a plugin may not be restored properly), but it is an acceptable result, as the rest of the configuration folder is restored properly. CURA-8313 --- cura/Backups/Backup.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cura/Backups/Backup.py b/cura/Backups/Backup.py index 6128dac320..1f6a961733 100644 --- a/cura/Backups/Backup.py +++ b/cura/Backups/Backup.py @@ -193,14 +193,13 @@ class Backup: Logger.log("d", "Removing current data in location: %s", target_path) Resources.factoryReset() Logger.log("d", "Extracting backup to location: %s", target_path) - try: - name_list = archive.namelist() - for archive_filename in name_list: + name_list = archive.namelist() + for archive_filename in name_list: + try: archive.extract(archive_filename, target_path) - CuraApplication.getInstance().processEvents() - except (PermissionError, EnvironmentError): - Logger.logException("e", "Unable to extract the backup due to permission or file system errors.") - return False + except (PermissionError, EnvironmentError): + Logger.logException("e", f"Unable to extract the file {archive_filename} from the backup due to permission or file system errors.") + CuraApplication.getInstance().processEvents() return True def _obfuscate(self) -> Dict[str, str]: