test: Detect truncated download in get_previous_releases.py

This commit is contained in:
MarcoFalke
2025-12-10 10:57:46 +01:00
parent cca113f5b0
commit fa75480c84

View File

@@ -122,7 +122,7 @@ def download_from_url(url, archive):
if response.status != 200:
raise RuntimeError(f"HTTP request failed with status code: {response.status}")
total_size = int(response.getheader('Content-Length', 0))
total_size = int(response.getheader("Content-Length"))
progress_bytes = 0
with open(archive, 'wb') as file:
@@ -134,6 +134,9 @@ def download_from_url(url, archive):
progress_bytes += len(chunk)
progress_hook(progress_bytes, total_size)
if progress_bytes < total_size:
raise RuntimeError(f"Download incomplete: expected {total_size} bytes, got {progress_bytes} bytes")
print('\n', flush=True, end="") # Flush to avoid error output on the same line.