mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-14 23:53:30 +00:00
Repair the file operation abnormality and add a log record
This commit is contained in:
parent
2cf95ed231
commit
9c957977d0
@ -1,9 +1,11 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import folder_paths
|
import folder_paths
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import shutil
|
import shutil
|
||||||
|
import traceback
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -29,8 +31,8 @@ class OutputManager:
|
|||||||
def add_routes(self, routes) -> None:
|
def add_routes(self, routes) -> None:
|
||||||
@routes.get("/output{pathname:.*}")
|
@routes.get("/output{pathname:.*}")
|
||||||
async def get_output_file_or_files(request):
|
async def get_output_file_or_files(request):
|
||||||
|
pathname = request.match_info.get("pathname", None)
|
||||||
try:
|
try:
|
||||||
pathname = request.match_info.get("pathname", None)
|
|
||||||
filepath = self.get_output_filepath(pathname)
|
filepath = self.get_output_filepath(pathname)
|
||||||
|
|
||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
@ -51,13 +53,15 @@ class OutputManager:
|
|||||||
return web.json_response(files)
|
return web.json_response(files)
|
||||||
|
|
||||||
return web.Response(status=404)
|
return web.Response(status=404)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
|
logging.error(f"File '{pathname}' retrieval failed")
|
||||||
|
logging.error(traceback.format_exc())
|
||||||
return web.Response(status=500)
|
return web.Response(status=500)
|
||||||
|
|
||||||
@routes.delete("/output{pathname:.*}")
|
@routes.delete("/output{pathname:.*}")
|
||||||
async def delete_output_file_or_files(request):
|
async def delete_output_file_or_files(request):
|
||||||
|
pathname = request.match_info.get("pathname", None)
|
||||||
try:
|
try:
|
||||||
pathname = request.match_info.get("pathname", None)
|
|
||||||
filepath = self.get_output_filepath(pathname)
|
filepath = self.get_output_filepath(pathname)
|
||||||
|
|
||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
@ -66,7 +70,9 @@ class OutputManager:
|
|||||||
shutil.rmtree(filepath)
|
shutil.rmtree(filepath)
|
||||||
self.rm_cache(filepath)
|
self.rm_cache(filepath)
|
||||||
return web.Response(status=200)
|
return web.Response(status=200)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
|
logging.error(f"File '{pathname}' deletion failed")
|
||||||
|
logging.error(traceback.format_exc())
|
||||||
return web.Response(status=500)
|
return web.Response(status=500)
|
||||||
|
|
||||||
def get_output_filepath(self, pathname: str):
|
def get_output_filepath(self, pathname: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user