diff --git a/plugins/3MFWriter/ThreeMFWorkspaceWriter.py b/plugins/3MFWriter/ThreeMFWorkspaceWriter.py index 4201573c78..2e113e0c4f 100644 --- a/plugins/3MFWriter/ThreeMFWorkspaceWriter.py +++ b/plugins/3MFWriter/ThreeMFWorkspaceWriter.py @@ -127,15 +127,19 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter): file_name = "Cura/%s.%s" % (container.getId(), file_suffix) - 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. + try: + 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) - # 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 = 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) + file_in_archive.compress_type = zipfile.ZIP_DEFLATED - # Do not include the network authentication keys - ignore_keys = {"network_authentication_id", "network_authentication_key", "octoprint_api_key"} - serialized_data = container.serialize(ignored_metadata_keys = ignore_keys) + # Do not include the network authentication keys + ignore_keys = {"network_authentication_id", "network_authentication_key", "octoprint_api_key"} + 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 \ No newline at end of file