Prevent crash when unable to write to storage location for container manager

Or the temp directory.

Fixes Sentry issue CURA-KY.
This commit is contained in:
Ghostkeeper 2020-04-23 13:48:05 +02:00
parent 75aafa1e5c
commit 52b4e98056
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,4 +1,4 @@
# Copyright (c) 2019 Ultimaker B.V.
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import os
@ -206,8 +206,11 @@ class ContainerManager(QObject):
if contents is None:
return {"status": "error", "message": "Serialization returned None. Unable to write to file"}
with SaveFile(file_url, "w") as f:
f.write(contents)
try:
with SaveFile(file_url, "w") as f:
f.write(contents)
except OSError:
return {"status": "error", "message": "Unable to write to this location.", "path": file_url}
return {"status": "success", "message": "Successfully exported container", "path": file_url}