diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-16 06:26:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 06:26:07 +0000 |
commit | 57e4422bdbf19134843a537a846314f06eb20b60 (patch) | |
tree | 843e99e96d40b49df3651e250954a0b52b0a22b0 /modules/ui_extra_networks.py | |
parent | 47d9dd0240872dc70fd26bc1bf309f49fe17c104 (diff) | |
parent | 8c11b126e5bd5052154c095177390f249e8e9889 (diff) | |
download | stable-diffusion-webui-gfx803-57e4422bdbf19134843a537a846314f06eb20b60.tar.gz stable-diffusion-webui-gfx803-57e4422bdbf19134843a537a846314f06eb20b60.tar.bz2 stable-diffusion-webui-gfx803-57e4422bdbf19134843a537a846314f06eb20b60.zip |
Merge pull request #11806 from huchenlei/file_500
404 when thumb file not found
Diffstat (limited to 'modules/ui_extra_networks.py')
-rw-r--r-- | modules/ui_extra_networks.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index f9d1fa31..760fba43 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -8,6 +8,7 @@ from modules.ui import up_down_symbol import gradio as gr
import json
import html
+from fastapi.exceptions import HTTPException
from modules.generation_parameters_copypaste import image_from_url_text
@@ -26,6 +27,9 @@ def register_page(page): def fetch_file(filename: str = ""):
from starlette.responses import FileResponse
+ if not os.path.isfile(filename):
+ raise HTTPException(status_code=404, detail="File not found")
+
if not any(Path(x).absolute() in Path(filename).absolute().parents for x in allowed_dirs):
raise ValueError(f"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages.")
|