mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-16 17:42:58 +08:00
Remove some functions the two deleted endpoints were using
This commit is contained in:
parent
c72236dd32
commit
20c57cbc6a
@ -208,27 +208,6 @@ def fetch_asset_info_asset_and_tags(
|
|||||||
tags.append(tag_name)
|
tags.append(tag_name)
|
||||||
return first_info, first_asset, tags
|
return first_info, first_asset, tags
|
||||||
|
|
||||||
def set_asset_info_preview(
|
|
||||||
session: Session,
|
|
||||||
asset_info_id: str,
|
|
||||||
preview_asset_id: str | None,
|
|
||||||
) -> None:
|
|
||||||
"""Set or clear preview_id and bump updated_at. Raises on unknown IDs."""
|
|
||||||
info = session.get(AssetInfo, asset_info_id)
|
|
||||||
if not info:
|
|
||||||
raise ValueError(f"AssetInfo {asset_info_id} not found")
|
|
||||||
|
|
||||||
if preview_asset_id is None:
|
|
||||||
info.preview_id = None
|
|
||||||
else:
|
|
||||||
# validate preview asset exists
|
|
||||||
if not session.get(Asset, preview_asset_id):
|
|
||||||
raise ValueError(f"Preview Asset {preview_asset_id} not found")
|
|
||||||
info.preview_id = preview_asset_id
|
|
||||||
|
|
||||||
info.updated_at = utcnow()
|
|
||||||
session.flush()
|
|
||||||
|
|
||||||
def list_tags_with_usage(
|
def list_tags_with_usage(
|
||||||
session: Session,
|
session: Session,
|
||||||
prefix: str | None = None,
|
prefix: str | None = None,
|
||||||
|
|||||||
@ -5,10 +5,8 @@ from app.assets.api import schemas_out
|
|||||||
from app.assets.database.queries import (
|
from app.assets.database.queries import (
|
||||||
asset_exists_by_hash,
|
asset_exists_by_hash,
|
||||||
fetch_asset_info_asset_and_tags,
|
fetch_asset_info_asset_and_tags,
|
||||||
get_asset_info_by_id,
|
|
||||||
list_asset_infos_page,
|
list_asset_infos_page,
|
||||||
list_tags_with_usage,
|
list_tags_with_usage,
|
||||||
set_asset_info_preview,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -99,43 +97,6 @@ def get_asset(asset_info_id: str, owner_id: str = "") -> schemas_out.AssetDetail
|
|||||||
last_access_time=info.last_access_time,
|
last_access_time=info.last_access_time,
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_asset_preview(
|
|
||||||
asset_info_id: str,
|
|
||||||
preview_asset_id: str | None,
|
|
||||||
owner_id: str = "",
|
|
||||||
) -> schemas_out.AssetDetail:
|
|
||||||
with create_session() as session:
|
|
||||||
info_row = get_asset_info_by_id(session, asset_info_id=asset_info_id)
|
|
||||||
if not info_row:
|
|
||||||
raise ValueError(f"AssetInfo {asset_info_id} not found")
|
|
||||||
if info_row.owner_id and info_row.owner_id != owner_id:
|
|
||||||
raise PermissionError("not owner")
|
|
||||||
|
|
||||||
set_asset_info_preview(
|
|
||||||
session,
|
|
||||||
asset_info_id=asset_info_id,
|
|
||||||
preview_asset_id=preview_asset_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
res = fetch_asset_info_asset_and_tags(session, asset_info_id=asset_info_id, owner_id=owner_id)
|
|
||||||
if not res:
|
|
||||||
raise RuntimeError("State changed during preview update")
|
|
||||||
info, asset, tags = res
|
|
||||||
session.commit()
|
|
||||||
|
|
||||||
return schemas_out.AssetDetail(
|
|
||||||
id=info.id,
|
|
||||||
name=info.name,
|
|
||||||
asset_hash=asset.hash if asset else None,
|
|
||||||
size=int(asset.size_bytes) if asset and asset.size_bytes is not None else None,
|
|
||||||
mime_type=asset.mime_type if asset else None,
|
|
||||||
tags=tags,
|
|
||||||
user_metadata=info.user_metadata or {},
|
|
||||||
preview_id=info.preview_id,
|
|
||||||
created_at=info.created_at,
|
|
||||||
last_access_time=info.last_access_time,
|
|
||||||
)
|
|
||||||
|
|
||||||
def list_tags(
|
def list_tags(
|
||||||
prefix: str | None = None,
|
prefix: str | None = None,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user