Fix for issue where temp file is empty (#6669)

This commit is contained in:
tofarr 2025-02-10 18:07:40 +00:00 committed by GitHub
parent 6c88b10c59
commit 2b40a92943
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -142,11 +142,13 @@ class ActionExecutionClient(Runtime):
stream=True,
timeout=30,
) as response:
temp_file = tempfile.NamedTemporaryFile(delete=False)
for chunk in response.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
temp_file.write(chunk)
return Path(temp_file.name)
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
total_length = 0
for chunk in response.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
total_length += len(chunk)
temp_file.write(chunk)
return Path(temp_file.name)
except requests.Timeout:
raise TimeoutError('Copy operation timed out')