fix: 渲染产物临时目录不在render_plan中提前清理,改由调用方上传后清理
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 32s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 33s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m52s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m55s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m15s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m20s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m7s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 549h52m8s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 549h52m10s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 549h52m38s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 549h52m42s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 549h52m40s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 549h52m44s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 549h52m44s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 550h26m3s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 550h26m33s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 550h26m37s

根因:render_plan的finally块在返回前shutil.rmtree清理了临时目录,
但generation.py还需要访问其中的文件进行OSS上传,导致FileNotFoundError。

修复:
1. RenderAdapterResult增加temp_dir字段
2. render_plan成功时将temp_dir传给result并置None阻止finally清理
3. render_plan失败时finally仍正常清理(异常路径不受影响)
4. generation.py在_upload_and_record完成后清理临时目录

新增4个回归测试验证清理时序正确。
This commit is contained in:
CI Bot
2026-08-24 17:33:01 +08:00
parent 7fdea8301c
commit 548eabbd2c
3 changed files with 82 additions and 3 deletions
@@ -84,6 +84,7 @@ class RenderAdapterResult:
cover_candidates: list[dict] | None = (
None # 封面候选帧 [{"image_url": "...", "frame_time": 5.0, "storage_key": "..."}]
)
temp_dir: str | None = None # 调用方负责清理的临时目录路径
def __post_init__(self):
if self.rendered_clip_ids is None:
@@ -200,7 +201,7 @@ class RenderAdapter:
self._report_progress(progress_cb, 35.0, "准备 BGM 音频")
# 3~6. 统一渲染核心流程(BGM + ASR + 渲染 + 缩略图 + 上传)
return self._do_render(
result = self._do_render(
plan=plan,
clips=ready_clips,
asset_path_map=asset_path_map,
@@ -212,6 +213,10 @@ class RenderAdapter:
failed_clip_ids=failed_clip_ids,
voiceover_audio_path=voiceover_audio_path,
)
# 将临时目录路径传递给调用方,由调用方负责清理
result.temp_dir = temp_dir
temp_dir = None # 成功时不清理,由调用方清理
return result
except subprocess.CalledProcessError as exc:
stderr_text = (exc.stderr or "").strip()