mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
Merge bitcoin/bitcoin#34040: test: Detect truncated download in get_previous_releases.py
fa75480c84ffecc856c2d76b1143b14ebce85d0b test: Detect truncated download in get_previous_releases.py (MarcoFalke) Pull request description: Without this, and end-of-stream is not detected and will just lead to an immediate exit, instead of a re-try. E.g. https://github.com/bitcoin/bitcoin/actions/runs/20089133013/job/57633839315?pr=34038#step:12:201: ``` ... Downloading: [##--------------------------------------] 5.4% Downloading: [##--------------------------------------] 5.4% Downloading: [##--------------------------------------] 5.5% Downloading: [##--------------------------------------] 5.6% Checksum dd02eab18f9154604e38135ef3f98fd310ba3c748074aeb83a71118cd2cd1367 did not match Error: Process completed with exit code 1. ``` Also, remove the `0` fallback value, because if the fallback was ever hit, the program would fail anyway with `division by zero` error. ACKs for top commit: Sjors: utACK fa75480c84ffecc856c2d76b1143b14ebce85d0b rkrux: Looks fine, ACK fa75480c84ffecc856c2d76b1143b14ebce85d0b l0rinc: code review ACK fa75480c84ffecc856c2d76b1143b14ebce85d0b Tree-SHA512: 230eaf155701ed833636b401118f11ff5c6521c61bf4f3a01fcf390a71a508ba6a570eea855ef659134e118b74f75e3d5772ec8a261db23ebfe4ac7ec87cab5a
This commit is contained in:
commit
c1f0a89d9c
@ -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.
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user