mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-09 11:20:03 +08:00
also download to a tmp file not the live file
to avoid compounding errors from network failure
This commit is contained in:
parent
c539ee55f4
commit
cfb5d6a532
@ -158,7 +158,10 @@ async def track_download_progress(response: aiohttp.ClientResponse,
|
||||
await progress_callback(model_name, status)
|
||||
last_update_time = time.time()
|
||||
|
||||
with open(file_path, 'wb') as f:
|
||||
if os.path.exists(file_path + '.tmp'):
|
||||
os.remove(file_path + '.tmp')
|
||||
|
||||
with open(file_path + '.tmp', 'wb') as f:
|
||||
chunk_iterator = response.content.iter_chunked(8192)
|
||||
while True:
|
||||
try:
|
||||
@ -171,6 +174,8 @@ async def track_download_progress(response: aiohttp.ClientResponse,
|
||||
if time.time() - last_update_time >= interval:
|
||||
await update_progress()
|
||||
|
||||
os.rename(file_path + '.tmp', file_path)
|
||||
|
||||
await update_progress()
|
||||
|
||||
logging.info(f"Successfully downloaded {model_name}. Total downloaded: {downloaded}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user