mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Don't crash when reading corrupt 3MF files
Otherwise it would crash with a BadZipFile error. We should be robust against that. This will trigger a generic message that we couldn't read that file to the user, and put more information in the log. Fixes Sentry issue CURA-NH.
This commit is contained in:
parent
dcac9b6a87
commit
abffb6c26c
1 changed files with 6 additions and 2 deletions
|
@ -738,11 +738,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
|
||||
@staticmethod
|
||||
def _loadMetadata(file_name: str) -> Dict[str, Dict[str, Any]]:
|
||||
archive = zipfile.ZipFile(file_name, "r")
|
||||
result = dict()
|
||||
try:
|
||||
archive = zipfile.ZipFile(file_name, "r")
|
||||
except zipfile.BadZipFile:
|
||||
Logger.logException("w", "Unable to retrieve metadata from {fname}: 3MF archive is corrupt.".format(fname = file_name))
|
||||
return result
|
||||
|
||||
metadata_files = [name for name in archive.namelist() if name.endswith("plugin_metadata.json")]
|
||||
|
||||
result = dict()
|
||||
|
||||
for metadata_file in metadata_files:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue