perf(8502): 并行生图(6并发)+超时重试;视频URL直连预览/下载;路径隔离
This commit is contained in:
@@ -113,6 +113,25 @@ class DBManager:
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
def update_project_product_info(self, project_id: str, product_info: Dict[str, Any]):
|
||||
"""
|
||||
Update project.product_info JSON (read-write with Postgres shared DB).
|
||||
Used to persist editor state without changing schema.
|
||||
"""
|
||||
session = self._get_session()
|
||||
try:
|
||||
project = session.query(Project).filter_by(id=project_id).first()
|
||||
if project:
|
||||
project.product_info = json.dumps(product_info, ensure_ascii=False)
|
||||
project.updated_at = time.time()
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
logger.error(f"Error updating product_info: {e}")
|
||||
raise
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
def update_project_status(self, project_id: str, status: str):
|
||||
session = self._get_session()
|
||||
try:
|
||||
@@ -260,6 +279,35 @@ class DBManager:
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
def update_asset_metadata(self, project_id: str, scene_id: int, asset_type: str, patch: Dict[str, Any]) -> None:
|
||||
"""Merge-patch asset.metadata JSON without overwriting other fields."""
|
||||
if not patch:
|
||||
return
|
||||
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
|
||||
try:
|
||||
existing = json.loads(asset.metadata_json) if asset.metadata_json else {}
|
||||
except Exception:
|
||||
existing = {}
|
||||
if not isinstance(existing, dict):
|
||||
existing = {}
|
||||
existing.update(patch)
|
||||
asset.metadata_json = json.dumps(existing, ensure_ascii=False)
|
||||
asset.updated_at = time.time()
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
logger.error(f"Error updating asset metadata: {e}")
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
# --- Config/Prompt Operations ---
|
||||
|
||||
def get_config(self, key: str, default: Any = None) -> Any:
|
||||
|
||||
Reference in New Issue
Block a user