mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Catch PermissionError when writing workspaces
We'll want to give a proper error message then. We have no mechanism right now to show a message on the screen particular to this error. Instead we'll let it fail (the user sees a message that writing fails) and put a message in the log why it failed. Fixes Sentry error CURA-DK.
This commit is contained in:
parent
7ab005e423
commit
2b003c30dc
1 changed files with 21 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import configparser
|
||||
|
@ -6,6 +6,7 @@ from io import StringIO
|
|||
import zipfile
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Logger import Logger
|
||||
from UM.Preferences import Preferences
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Workspace.WorkspaceWriter import WorkspaceWriter
|
||||
|
@ -25,6 +26,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
|
||||
Logger.error("3MF Writer class is unavailable. Can't write workspace.")
|
||||
return False
|
||||
|
||||
# Indicate that the 3mf mesh writer should not close the archive just yet (we still need to add stuff to it).
|
||||
|
@ -59,6 +61,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
|||
preferences_string = StringIO()
|
||||
temp_preferences.writeToFile(preferences_string)
|
||||
preferences_file = zipfile.ZipInfo("Cura/preferences.cfg")
|
||||
try:
|
||||
archive.writestr(preferences_file, preferences_string.getvalue())
|
||||
|
||||
# Save Cura version
|
||||
|
@ -77,6 +80,9 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
|||
|
||||
# Close the archive & reset states.
|
||||
archive.close()
|
||||
except PermissionError:
|
||||
Logger.error("No permission to write workspace to this stream.")
|
||||
return False
|
||||
mesh_writer.setStoreArchive(False)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue