From 3145fdb534a9069d8f9dbbd78f87ee48b52e12a5 Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 29 Oct 2021 14:19:52 +0200 Subject: [PATCH] [models] Make manifest deserializer skip unknown data instead of failing --- legendary/models/manifest.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/legendary/models/manifest.py b/legendary/models/manifest.py index c43cc39..28ea004 100644 --- a/legendary/models/manifest.py +++ b/legendary/models/manifest.py @@ -118,10 +118,10 @@ class Manifest: _manifest.version = struct.unpack(' 0: _meta._build_id = read_fstring(bio) - if bio.tell() != _meta.meta_size: - raise ValueError('Did not read entire meta!') + if (size_read := bio.tell()) != _meta.meta_size: + logger.warning(f'Did not read entire manifest metadata! Version: {_meta.data_version}, ' + f'{_meta.meta_size - size_read} bytes missing, skipping...') + bio.seek(_meta.meta_size - size_read, 1) + # downgrade version to prevent issues during serialisation + _meta.data_version = 0 return _meta @@ -366,8 +370,12 @@ class CDL: for chunk in _cdl.elements: chunk.file_size = struct.unpack('