chore: improve the download code
This commit is contained in:
@ -40,13 +40,9 @@ async def _download_file(file_url: str, file_name: str, file_path: Path | str, f
|
||||
if rsp.status == 416:
|
||||
return
|
||||
rsp.raise_for_status()
|
||||
while True:
|
||||
chunk = await rsp.content.read(chunks)
|
||||
await asyncio.sleep(0)
|
||||
if not chunk:
|
||||
break
|
||||
with file_path.open("ab") as f:
|
||||
f.write(chunk)
|
||||
with file_path.open("ab") as f:
|
||||
async for data in rsp.content.iter_chunked(chunks):
|
||||
f.write(data)
|
||||
|
||||
|
||||
def calculate_md5(file_to_calculate):
|
||||
|
||||
Reference in New Issue
Block a user