Skip to content

Commit fa75480

Browse files
author
MarcoFalke
committed
test: Detect truncated download in get_previous_releases.py
1 parent cca113f commit fa75480

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/get_previous_releases.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def progress_hook(progress_bytes, total_size):
122122
if response.status != 200:
123123
raise RuntimeError(f"HTTP request failed with status code: {response.status}")
124124

125-
total_size = int(response.getheader('Content-Length', 0))
125+
total_size = int(response.getheader("Content-Length"))
126126
progress_bytes = 0
127127

128128
with open(archive, 'wb') as file:
@@ -134,6 +134,9 @@ def progress_hook(progress_bytes, total_size):
134134
progress_bytes += len(chunk)
135135
progress_hook(progress_bytes, total_size)
136136

137+
if progress_bytes < total_size:
138+
raise RuntimeError(f"Download incomplete: expected {total_size} bytes, got {progress_bytes} bytes")
139+
137140
print('\n', flush=True, end="") # Flush to avoid error output on the same line.
138141

139142

0 commit comments

Comments
 (0)