From ecf6572e5fa944b0f91249e644fd64bcd268010e Mon Sep 17 00:00:00 2001 From: derrod Date: Sat, 16 May 2020 16:55:30 +0200 Subject: [PATCH] [utils] Show warning if savegame got truncated during packing --- legendary/utils/savegame_helper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/legendary/utils/savegame_helper.py b/legendary/utils/savegame_helper.py index 0895085..48f4a8f 100644 --- a/legendary/utils/savegame_helper.py +++ b/legendary/utils/savegame_helper.py @@ -125,6 +125,11 @@ class SaveGameHelper: cp = ChunkPart(guid=cur_chunk.guid, offset=cur_buffer.tell(), size=min(remaining, 1024 * 1024 - cur_buffer.tell())) _tmp = cf.read(cp.size) + if not _tmp: + self.log.warning(f'Got EOF for "{f.filename}" with {remaining} bytes remaining! ' + f'File may have been corrupted/modified.') + break + cur_buffer.write(_tmp) fhash.update(_tmp) # update sha1 hash with new data f.chunk_parts.append(cp)