Keep generated template previews out of photo selection

This commit is contained in:
Pigway
2026-10-05 00:31:56 +08:00
parent a180dbc076
commit 5dc10a10e9
5 changed files with 32 additions and 6 deletions
+9 -4
View File
@@ -3,7 +3,7 @@ import os
import re
from contextlib import asynccontextmanager
from pathlib import Path
from typing import Any
from typing import Any, Literal
from uuid import uuid4
from fastapi import Depends, FastAPI, File, Form, Header, Query, Request, UploadFile
@@ -479,12 +479,17 @@ def create_app(settings=None, start_worker=True):
tags=["Images"],
dependencies=[Depends(require("images:read"))],
)
def list_assets(limit: int = Query(default=100, ge=1, le=200)):
def list_assets(
limit: int = Query(default=100, ge=1, le=200),
source: Literal["all", "uploaded", "generated"] = "all",
):
return [
assets.info(r["id"])
for r in db.all(
"SELECT id FROM assets WHERE kind!='cache' ORDER BY created_at DESC LIMIT ?",
(limit,),
"SELECT id FROM assets WHERE kind!='cache' AND "
"(?='all' OR (?='uploaded' AND kind='images') OR (?='generated' AND kind='generated')) "
"ORDER BY created_at DESC LIMIT ?",
(source, source, source, limit),
)
]