Show error when we don't have permission to write workspace

Fixes several Sentry issues, among which Cura-EG.
This commit is contained in:
Ghostkeeper 2020-03-30 14:00:36 +02:00
parent be85e6d75e
commit f34edd6bec
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -10,6 +10,8 @@ from UM.Logger import Logger
from UM.Preferences import Preferences
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Workspace.WorkspaceWriter import WorkspaceWriter
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
from cura.Utils.Threading import call_on_qt_thread
@ -26,6 +28,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
mesh_writer = application.getMeshFileHandler().getWriter("3MFWriter")
if not mesh_writer: # We need to have the 3mf mesh writer, otherwise we can't save the entire workspace
self.setInformation(catalog.i18nc("@error:zip", "3MF Writer plug-in is corrupt."))
Logger.error("3MF Writer class is unavailable. Can't write workspace.")
return False
@ -39,6 +42,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
global_stack = machine_manager.activeMachine
try:
# Add global container stack data to the archive.
self._writeContainerToArchive(global_stack, archive)
@ -51,6 +55,10 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
self._writeContainerToArchive(extruder_stack, archive)
for container in extruder_stack.getContainers():
self._writeContainerToArchive(container, archive)
except PermissionError:
self.setInformation(catalog.i18nc("@error:zip", "No permission to write the workspace here."))
Logger.error("No permission to write workspace to this stream.")
return False
# Write preferences to archive
original_preferences = Application.getInstance().getPreferences() #Copy only the preferences that we use to the workspace.
@ -81,6 +89,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
# Close the archive & reset states.
archive.close()
except PermissionError:
self.setInformation(catalog.i18nc("@error:zip", "No permission to write the workspace here."))
Logger.error("No permission to write workspace to this stream.")
return False
mesh_writer.setStoreArchive(False)