mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
Catch file writing errors while writing files in the archive
Seems really rare to me, but our users get every possible error some day. Fixes Sentry issue CURA-ZW.
This commit is contained in:
parent
3032221b70
commit
c7bbc139f7
1 changed files with 13 additions and 9 deletions
|
@ -127,15 +127,19 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
||||||
|
|
||||||
file_name = "Cura/%s.%s" % (container.getId(), file_suffix)
|
file_name = "Cura/%s.%s" % (container.getId(), file_suffix)
|
||||||
|
|
||||||
if file_name in archive.namelist():
|
try:
|
||||||
return # File was already saved, no need to do it again. Uranium guarantees unique ID's, so this should hold.
|
if file_name in archive.namelist():
|
||||||
|
return # File was already saved, no need to do it again. Uranium guarantees unique ID's, so this should hold.
|
||||||
|
|
||||||
file_in_archive = zipfile.ZipInfo(file_name)
|
file_in_archive = zipfile.ZipInfo(file_name)
|
||||||
# For some reason we have to set the compress type of each file as well (it doesn't keep the type of the entire archive)
|
# For some reason we have to set the compress type of each file as well (it doesn't keep the type of the entire archive)
|
||||||
file_in_archive.compress_type = zipfile.ZIP_DEFLATED
|
file_in_archive.compress_type = zipfile.ZIP_DEFLATED
|
||||||
|
|
||||||
# Do not include the network authentication keys
|
# Do not include the network authentication keys
|
||||||
ignore_keys = {"network_authentication_id", "network_authentication_key", "octoprint_api_key"}
|
ignore_keys = {"network_authentication_id", "network_authentication_key", "octoprint_api_key"}
|
||||||
serialized_data = container.serialize(ignored_metadata_keys = ignore_keys)
|
serialized_data = container.serialize(ignored_metadata_keys = ignore_keys)
|
||||||
|
|
||||||
archive.writestr(file_in_archive, serialized_data)
|
archive.writestr(file_in_archive, serialized_data)
|
||||||
|
except (FileNotFoundError, EnvironmentError):
|
||||||
|
Logger.error("File became inaccessible while writing to it: {archive_filename}".format(archive_filename = archive.fp.name))
|
||||||
|
return
|
Loading…
Add table
Add a link
Reference in a new issue