fix(8502): 重生图片自动作废旧视频;记录来源图片签名并提示stale;组图/重生视频路径唯一化
This commit is contained in:
@@ -308,6 +308,59 @@ class DBManager:
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
def clear_asset(self, project_id: str, scene_id: int, asset_type: str, *, status: str = "pending") -> None:
|
||||
"""
|
||||
Clear an asset record (keep the row, but remove paths/task/metadata).
|
||||
Used to invalidate stale videos after images are regenerated.
|
||||
"""
|
||||
session = self._get_session()
|
||||
try:
|
||||
asset = session.query(SceneAsset).filter_by(
|
||||
project_id=project_id,
|
||||
scene_id=scene_id,
|
||||
asset_type=asset_type,
|
||||
).first()
|
||||
if not asset:
|
||||
return
|
||||
asset.status = status
|
||||
asset.local_path = None
|
||||
asset.remote_url = None
|
||||
asset.task_id = None
|
||||
asset.metadata_json = "{}"
|
||||
asset.updated_at = time.time()
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
logger.error(f"Error clearing asset: {e}")
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
def clear_assets(self, project_id: str, asset_type: str, *, status: str = "pending") -> int:
|
||||
"""
|
||||
Clear all assets of a type for a project. Returns number of rows affected.
|
||||
"""
|
||||
session = self._get_session()
|
||||
try:
|
||||
q = session.query(SceneAsset).filter_by(project_id=project_id, asset_type=asset_type)
|
||||
rows = q.all()
|
||||
if not rows:
|
||||
return 0
|
||||
for asset in rows:
|
||||
asset.status = status
|
||||
asset.local_path = None
|
||||
asset.remote_url = None
|
||||
asset.task_id = None
|
||||
asset.metadata_json = "{}"
|
||||
asset.updated_at = time.time()
|
||||
session.commit()
|
||||
return len(rows)
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
logger.error(f"Error clearing assets: {e}")
|
||||
return 0
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
# --- Config/Prompt Operations ---
|
||||
|
||||
def get_config(self, key: str, default: Any = None) -> Any:
|
||||
|
||||
Reference in New Issue
Block a user