-
Notifications
You must be signed in to change notification settings - Fork 39.2k
test: Detect truncated download in get_previous_releases.py #34040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ def progress_hook(progress_bytes, total_size): | |
| 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 progress_hook(progress_bytes, total_size): | |
| progress_bytes += len(chunk) | ||
| progress_hook(progress_bytes, total_size) | ||
|
|
||
| if progress_bytes < total_size: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could be stricter and make it
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will leave as-is for now
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, |
||
| 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. | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If missing, this would fail with
TypeError, right?nit to minimize diff:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blackprefers this, so I'll leave this as-is for now