Catch environment errors removing temporary package files

Could be removed or not having access rights.

Fixes Sentry issue CURA-1K6.
This commit is contained in:
Ghostkeeper 2021-01-19 14:49:47 +01:00
parent 1b8463ba30
commit a9c8c63442
No known key found for this signature in database
GPG key ID: 14C3586CD2EFC5B9

View file

@ -1,3 +1,6 @@
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import os import os
from typing import List, Dict, Any, cast from typing import List, Dict, Any, cast
@ -96,7 +99,10 @@ class SyncOrchestrator(Extension):
else: else:
self._cloud_api.unsubscribe(item["package_id"]) self._cloud_api.unsubscribe(item["package_id"])
# delete temp file # delete temp file
try:
os.remove(item["package_path"]) 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: if has_changes:
self._restart_presenter.present() self._restart_presenter.present()