diff --git a/apps/worker/worker_app/tasks/edit_plan_generation.py b/apps/worker/worker_app/tasks/edit_plan_generation.py index f1dd917c2..729a202ce 100644 --- a/apps/worker/worker_app/tasks/edit_plan_generation.py +++ b/apps/worker/worker_app/tasks/edit_plan_generation.py @@ -241,9 +241,16 @@ def _render_with_unified( return {"status": "error", "message": result.error_message or "渲染失败"} output_path = result.output_path or Path("") - output_url = result.output_url + output_url = result.output_url or "" thumbnail_url = result.thumbnail_url or "" - storage_key = f"rendered/{plan_id}/output.mp4" + # adapter 上传到 rendered/{plan_id}/{job_id}.mp4,从 URL 提取实际 key + # 不能用 output.mp4 硬编码,否则 cover 等下游通过 key 构造的 URL 指向不存在的文件 + if output_url: + from packages.shared.storage import get_shared_storage_service + + storage_key = get_shared_storage_service().normalize_storage_key(output_url) + else: + storage_key = f"rendered/{plan_id}/{generation_task_id or plan_id}.mp4" # 用 adapter 返回的 clip 明细(以 adapter 的结果为准) rendered_clip_ids = result.rendered_clip_ids or [] diff --git a/apps/worker/worker_app/tasks/generation.py b/apps/worker/worker_app/tasks/generation.py index 62be2f660..f641e66c6 100644 --- a/apps/worker/worker_app/tasks/generation.py +++ b/apps/worker/worker_app/tasks/generation.py @@ -1262,7 +1262,9 @@ def _upload_and_record( Returns: (file_url, duration, file_size, video_count) """ - storage_key = f"generated/projects/{project_id}/tasks/{task_id}/{output_path.name}" + # project_id 可能为空(模板编辑器草稿不属于任何项目),过滤空段避免 OSS key 出现 // + path_parts = [p for p in ("generated", "projects", project_id, "tasks", task_id, output_path.name) if p] + storage_key = "/".join(path_parts) file_size = output_path.stat().st_size # 上传 OSS