diff --git a/scripts/api.py b/scripts/api.py index bb3feec..4e28e9e 100644 --- a/scripts/api.py +++ b/scripts/api.py @@ -373,12 +373,7 @@ def infinite_image_browsing_api(_: Any, app: FastAPI, **kwargs): img = DbImg.get(conn, path) if not img: if DbImg.count(conn) == 0: - raise HTTPException( - 400, - "你需要先通过图像搜索页生成索引" - if locale == "zh" - else "You need to generate an index through the image search page first.", - ) + return [] update_image_data([os.path.dirname(path)]) img = DbImg.get(conn, path) assert img @@ -401,6 +396,13 @@ def infinite_image_browsing_api(_: Any, app: FastAPI, **kwargs): else "Tag toggleing is not supported outside the Stable Diffusion webui folder. Please open an issue if you have any questions.", ) img = DbImg.get(conn, path) + if not img: + raise HTTPException( + 400, + "你需要先通过图像搜索页生成索引" + if locale == "zh" + else "You need to generate an index through the image search page first.", + ) tags = ImageTag.get_tags_for_image( conn=conn, image_id=img.id, type="custom", tag_id=req.tag_id )