|
5 | 5 | from app.assets.database.queries import ( |
6 | 6 | asset_exists_by_hash, |
7 | 7 | fetch_asset_info_asset_and_tags, |
8 | | - get_asset_info_by_id, |
9 | 8 | list_asset_infos_page, |
10 | 9 | list_tags_with_usage, |
11 | | - set_asset_info_preview, |
12 | 10 | ) |
13 | 11 |
|
14 | 12 |
|
@@ -99,43 +97,6 @@ def get_asset(asset_info_id: str, owner_id: str = "") -> schemas_out.AssetDetail |
99 | 97 | last_access_time=info.last_access_time, |
100 | 98 | ) |
101 | 99 |
|
102 | | -def set_asset_preview( |
103 | | - asset_info_id: str, |
104 | | - preview_asset_id: str | None, |
105 | | - owner_id: str = "", |
106 | | -) -> schemas_out.AssetDetail: |
107 | | - with create_session() as session: |
108 | | - info_row = get_asset_info_by_id(session, asset_info_id=asset_info_id) |
109 | | - if not info_row: |
110 | | - raise ValueError(f"AssetInfo {asset_info_id} not found") |
111 | | - if info_row.owner_id and info_row.owner_id != owner_id: |
112 | | - raise PermissionError("not owner") |
113 | | - |
114 | | - set_asset_info_preview( |
115 | | - session, |
116 | | - asset_info_id=asset_info_id, |
117 | | - preview_asset_id=preview_asset_id, |
118 | | - ) |
119 | | - |
120 | | - res = fetch_asset_info_asset_and_tags(session, asset_info_id=asset_info_id, owner_id=owner_id) |
121 | | - if not res: |
122 | | - raise RuntimeError("State changed during preview update") |
123 | | - info, asset, tags = res |
124 | | - session.commit() |
125 | | - |
126 | | - return schemas_out.AssetDetail( |
127 | | - id=info.id, |
128 | | - name=info.name, |
129 | | - asset_hash=asset.hash if asset else None, |
130 | | - size=int(asset.size_bytes) if asset and asset.size_bytes is not None else None, |
131 | | - mime_type=asset.mime_type if asset else None, |
132 | | - tags=tags, |
133 | | - user_metadata=info.user_metadata or {}, |
134 | | - preview_id=info.preview_id, |
135 | | - created_at=info.created_at, |
136 | | - last_access_time=info.last_access_time, |
137 | | - ) |
138 | | - |
139 | 100 | def list_tags( |
140 | 101 | prefix: str | None = None, |
141 | 102 | limit: int = 100, |
|
0 commit comments