From 0d1537963c1b7546695cac3a13abd018e6fa9d0d Mon Sep 17 00:00:00 2001 From: bennykok Date: Tue, 17 Sep 2024 21:48:42 -0700 Subject: [PATCH] fix --- custom_routes.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/custom_routes.py b/custom_routes.py index 7c98e41..7a229be 100644 --- a/custom_routes.py +++ b/custom_routes.py @@ -1363,7 +1363,7 @@ async def update_file_status(prompt_id: str, data, uploading, have_error=False, async def handle_upload(prompt_id: str, data, key: str, content_type_key: str, default_content_type: str): items = data.get(key, []) - # upload_tasks = [] + upload_tasks = [] for item in items: # Skipping temp files @@ -1379,33 +1379,43 @@ async def handle_upload(prompt_id: str, data, key: str, content_type_key: str, d elif file_extension == '.webp': file_type = 'image/webp' - # upload_tasks.append(upload_file( - # prompt_id, - # item.get("filename"), - # subfolder=item.get("subfolder"), - # type=item.get("type"), - # content_type=file_type, - # item=item - # )) - await upload_file( + upload_tasks.append(upload_file( prompt_id, item.get("filename"), subfolder=item.get("subfolder"), type=item.get("type"), content_type=file_type, item=item - ) + )) + # await upload_file( + # prompt_id, + # item.get("filename"), + # subfolder=item.get("subfolder"), + # type=item.get("type"), + # content_type=file_type, + # item=item + # ) # Execute all upload tasks concurrently - # await asyncio.gather(*upload_tasks) + await asyncio.gather(*upload_tasks) # Upload files in the background async def upload_in_background(prompt_id: str, data, node_id=None, have_upload=True, node_meta=None): try: - await handle_upload(prompt_id, data, 'images', "content_type", "image/png") - await handle_upload(prompt_id, data, 'files', "content_type", "image/png") - await handle_upload(prompt_id, data, 'gifs', "format", "image/gif") - await handle_upload(prompt_id, data, 'mesh', "format", "application/octet-stream") + # await handle_upload(prompt_id, data, 'images', "content_type", "image/png") + # await handle_upload(prompt_id, data, 'files', "content_type", "image/png") + # await handle_upload(prompt_id, data, 'gifs', "format", "image/gif") + # await handle_upload(prompt_id, data, 'mesh', "format", "application/octet-stream") + upload_tasks = [ + handle_upload(prompt_id, data, "images", "content_type", "image/png"), + handle_upload(prompt_id, data, "files", "content_type", "image/png"), + handle_upload(prompt_id, data, "gifs", "format", "image/gif"), + handle_upload( + prompt_id, data, "mesh", "format", "application/octet-stream" + ), + ] + + await asyncio.gather(*upload_tasks) status_endpoint = prompt_metadata[prompt_id].status_endpoint token = prompt_metadata[prompt_id].token