Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Ha <jackha@gmail.com>2018-02-08 16:19:47 +0300
committerJack Ha <jackha@gmail.com>2018-02-08 16:19:47 +0300
commit8bb70d6cc2747baacdec9d668e2159f03f2977d6 (patch)
tree85023cc52e79b144079da8929ab13a590668ff5f /cura/CrashHandler.py
parentf29d07ce40c0b15b0b07630cb02dc1f832135bd3 (diff)
CURA-4934 fix crash handler cleanup in some rare case
Diffstat (limited to 'cura/CrashHandler.py')
-rw-r--r--cura/CrashHandler.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py
index fa09db3e50..4d8cb6f54d 100644
--- a/cura/CrashHandler.py
+++ b/cura/CrashHandler.py
@@ -162,12 +162,15 @@ class CrashHandler:
file_name = base_name + "_" + date_now + "_" + idx
zip_file_path = os.path.join(root_dir, file_name + ".zip")
try:
- # remove the .zip extension because make_archive() adds it
- zip_file_path = zip_file_path[:-4]
- shutil.make_archive(zip_file_path, "zip", root_dir = root_dir, base_dir = base_name)
+ # only create the zip backup when the folder exists
+ if os.path.exists(folder):
+ # remove the .zip extension because make_archive() adds it
+ zip_file_path = zip_file_path[:-4]
+ shutil.make_archive(zip_file_path, "zip", root_dir = root_dir, base_dir = base_name)
+
+ # remove the folder only when the backup is successful
+ shutil.rmtree(folder, ignore_errors = True)
- # remove the folder only when the backup is successful
- shutil.rmtree(folder, ignore_errors = True)
# create an empty folder so Resources will not try to copy the old ones
os.makedirs(folder, 0o0755, exist_ok=True)