Browse Source

Don't crash if a material fails to be written in the zip

This fixes Sentry issue CURA-2WS.
Konstantinos Karmas 3 years ago
parent
commit
fe640d42cf
1 changed files with 4 additions and 1 deletions
  1. 4 1
      cura/Machines/Models/MaterialManagementModel.py

+ 4 - 1
cura/Machines/Models/MaterialManagementModel.py

@@ -296,4 +296,7 @@ class MaterialManagementModel(QObject):
             material = registry.findContainers(id = metadata["id"])[0]
             suffix = registry.getMimeTypeForContainer(type(material)).preferredSuffix
             filename = metadata["id"] + "." + suffix
-            archive.writestr(filename, material.serialize())
+            try:
+                archive.writestr(filename, material.serialize())
+            except OSError as e:
+                Logger.log("e", f"An error has occurred while writing the material \'{metadata['id']}\' in the file \'{filename}\': {e}.")