From fc58940ed67f8b8b6c55f1b7ccc44c9da2d7b561 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Thu, 6 Feb 2020 09:41:43 +0100 Subject: [PATCH] fix: [core Global] catch and log incomplete files --- bin/Global.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/Global.py b/bin/Global.py index 7ef3c78e..9a6b37e2 100755 --- a/bin/Global.py +++ b/bin/Global.py @@ -114,9 +114,14 @@ if __name__ == '__main__': print('File already exist {}'.format(filename)) publisher.warning('Global; File already exist') + try: + with gzip.open(filename, 'rb') as f: + curr_file_content = f.read() + except EOFError: + publisher.warning('Global; Incomplete file: {}'.format(filename)) + # discard item + continue - with gzip.open(filename, 'rb') as f: - curr_file_content = f.read() curr_file_md5 = hashlib.md5(curr_file_content).hexdigest() new_file_content = gunzip_bytes_obj(decoded)