From 6b67bb948b256c5452739ee8d37ec0dfea86008c Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 24 Aug 2026 20:59:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86try=E5=9D=97=E4=B8=8A=E7=A7=BB?= =?UTF-8?q?=E5=88=B0render=5Ftemp=5Fdir=E8=B5=8B=E5=80=BC=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=BC=82=E5=B8=B8=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E6=B8=85=E7=90=86=E4=B8=B4=E6=97=B6=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/worker/worker_app/tasks/generation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/worker/worker_app/tasks/generation.py b/apps/worker/worker_app/tasks/generation.py index 4e866227a..e40f74e52 100644 --- a/apps/worker/worker_app/tasks/generation.py +++ b/apps/worker/worker_app/tasks/generation.py @@ -699,16 +699,16 @@ def generate_video(self, task_id: str) -> dict: task_info=task_info, ) ) - - if gen_task: - gen_task.append_log("渲染", f"渲染完成, 时长={render_duration:.1f}s") - _flush_logs(task_id, gen_task) - - _update_task_progress(task_id, 80, "渲染完成") - - # ── 4. 上传 OSS + 查重记录(临时目录在 finally 中清理)─────── - _update_task_progress(task_id, 85, "开始上传") + # 从这里开始,render_temp_dir 已赋值,必须确保异常时也能清理 try: + if gen_task: + gen_task.append_log("渲染", f"渲染完成, 时长={render_duration:.1f}s") + _flush_logs(task_id, gen_task) + + _update_task_progress(task_id, 80, "渲染完成") + + # ── 4. 上传 OSS + 查重记录 ─────────────────────────────── + _update_task_progress(task_id, 85, "开始上传") file_url, duration, file_size, video_count = _upload_and_record( task_id=task_id, output_path=output_path, @@ -730,7 +730,7 @@ def generate_video(self, task_id: str) -> dict: _update_task_progress(task_id, 95, "上传完成") finally: - # 清理渲染临时目录(无论上传成功与否都清理) + # 清理渲染临时目录(无论后续步骤成功与否都清理) if render_temp_dir: import shutil