From 72fee02ec47f675666f5a58684bda5da2a6c8dc5 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 12 Aug 2025 11:26:50 +0100 Subject: [PATCH] ensure chunk is either null or empty to exit loop --- apps/epg/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/epg/tasks.py b/apps/epg/tasks.py index 452478a2..087d9fba 100644 --- a/apps/epg/tasks.py +++ b/apps/epg/tasks.py @@ -645,7 +645,7 @@ def extract_compressed_file(file_path, output_path=None, delete_original=False): with open(extracted_path, 'wb') as out_file: while True: chunk = gz_file.read(MAX_EXTRACT_CHUNK_SIZE) - if not chunk: + if not chunk or len(chunk) == 0: break out_file.write(chunk) except Exception as e: @@ -695,7 +695,7 @@ def extract_compressed_file(file_path, output_path=None, delete_original=False): with zip_file.open(xml_files[0], "r") as xml_file: while True: chunk = xml_file.read(MAX_EXTRACT_CHUNK_SIZE) - if not chunk: + if not chunk or len(chunk) == 0: break out_file.write(chunk)