From f00459e4cc10cfa1b351b2e15cae1f1eec6305bb Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 17 May 2018 09:32:18 +0200 Subject: [PATCH] revert --- cura/Backups/Backup.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cura/Backups/Backup.py b/cura/Backups/Backup.py index aeffcf80eb..615fb45297 100644 --- a/cura/Backups/Backup.py +++ b/cura/Backups/Backup.py @@ -138,7 +138,8 @@ class Backup: return extracted - def _extractArchive(self, archive: "ZipFile", target_path: str) -> bool: + @staticmethod + def _extractArchive(archive: "ZipFile", target_path: str) -> bool: """ Extract the whole archive to the given target path. :param archive: The archive as ZipFile. @@ -147,7 +148,7 @@ class Backup: """ Logger.log("d", "Removing current data in location: %s", target_path) try: - shutil.rmtree(target_path, onerror=self._onRemoveError) + 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. @@ -156,10 +157,3 @@ class Backup: Logger.log("d", "Extracting backup to location: %s", target_path) archive.extractall(target_path) return True - - @staticmethod - def _onRemoveError(*args): - import stat # needed for file stat - func, path, _ = args # onerror returns a tuple containing function, path and exception info - os.chmod(path, stat.S_IWRITE) - os.remove(path)