Skip to content
Merged
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions ayon_api/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ def _download_file_to_stream(
get_func = self._session_functions_mapping[RequestTypes.get]

retries = self.get_default_max_retries()
content_size_set = False
for attempt in range(retries):
# Continue in download
offset = progress.get_transferred_size()
Expand All @@ -1377,9 +1378,12 @@ def _download_file_to_stream(
try:
with get_func(url, **kwargs) as response:
response.raise_for_status()
progress.set_content_size(
response.headers["Content-length"]
)
if not content_size_set:
content_size_set = True
progress.set_content_size(
response.headers["Content-length"]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not do if progress.get_content_size() is None: - instead of having a local variable here to maintain?


for chunk in response.iter_content(chunk_size=chunk_size):
stream.write(chunk)
progress.add_transferred_chunk(len(chunk))
Expand Down