mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix file chunking corruption (#7338)
This commit is contained in:
parent
b0030d3a2b
commit
3856a896ea
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import threading
|
||||
from abc import abstractmethod
|
||||
@ -149,7 +148,10 @@ class ActionExecutionClient(Runtime):
|
||||
with tempfile.NamedTemporaryFile(
|
||||
suffix='.zip', delete=False
|
||||
) as temp_file:
|
||||
shutil.copyfileobj(response.raw, temp_file, length=16 * 1024)
|
||||
for chunk in response.iter_content(chunk_size=16 * 1024):
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
temp_file.write(chunk)
|
||||
temp_file.flush()
|
||||
return Path(temp_file.name)
|
||||
except requests.Timeout:
|
||||
raise TimeoutError('Copy operation timed out')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user