Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/get_previous_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Copy link
Copy Markdown
Contributor

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:

Suggested change
total_size = int(response.getheader("Content-Length"))
total_size = int(response.getheader('Content-Length'))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

black prefers this, so I'll leave this as-is for now

progress_bytes = 0

with open(archive, 'wb') as file:
Expand All @@ -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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could be stricter and make it !=

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will leave as-is for now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, progress_bytes < total_size: could be considered stricter, because if the server starts replying with the wrong payload size, or appends data, it seems like this could be useful to know via a checksum error.

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.


Expand Down
Loading