Browse Source

Catch environment errors removing temporary package files

Could be removed or not having access rights.

Fixes Sentry issue CURA-1K6.
Ghostkeeper 4 years ago
parent
commit
a9c8c63442
1 changed files with 7 additions and 1 deletions
  1. 7 1
      plugins/Toolbox/src/CloudSync/SyncOrchestrator.py

+ 7 - 1
plugins/Toolbox/src/CloudSync/SyncOrchestrator.py

@@ -1,3 +1,6 @@
+# Copyright (c) 2021 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
 import os
 from typing import List, Dict, Any, cast
 
@@ -96,7 +99,10 @@ class SyncOrchestrator(Extension):
             else:
                 self._cloud_api.unsubscribe(item["package_id"])
             # delete temp file
-            os.remove(item["package_path"])
+            try:
+                os.remove(item["package_path"])
+            except EnvironmentError as e:  # File was already removed, no access rights, etc.
+                Logger.error("Can't delete temporary package file: {err}".format(err = str(e)))
 
         if has_changes:
             self._restart_presenter.present()