mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
test: Detect truncated download in get_previous_releases.py
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user