From eb436a8b0e1ee259c5871fef57f6d19f60f811ad Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 17 May 2018 09:13:55 +0200 Subject: [PATCH] Ignore permission error on Windows when trying to remove log file --- cura/Backups/Backup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cura/Backups/Backup.py b/cura/Backups/Backup.py index ffa0edc80f..615fb45297 100644 --- a/cura/Backups/Backup.py +++ b/cura/Backups/Backup.py @@ -147,7 +147,13 @@ class Backup: :return: A boolean whether we had success or not. """ Logger.log("d", "Removing current data in location: %s", target_path) - shutil.rmtree(target_path) + try: + shutil.rmtree(target_path) + except PermissionError as error: + # This happens if a file is already opened by another program, usually only the log file. + # For now we just ignore this as it doesn't harm the restore process. + Logger.log("w", "Permission error while trying to remove tree: %s", error) + pass Logger.log("d", "Extracting backup to location: %s", target_path) archive.extractall(target_path) return True