From fa17ffa9a846a981bbde21452a266b5bcaf08ac6 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Wed, 23 Sep 2026 09:48:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(download-center):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=B8=AD=E5=88=A0=E9=99=A4=E4=BB=BB=E5=8A=A1=E6=97=B6=E4=B8=A2?= =?UTF-8?q?=E5=BC=83=E4=BA=A7=E7=89=A9=EF=BC=8C=E5=B9=B6=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=BF=90=E8=A1=8C=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- furniture-3d-system/.gitignore | 3 +++ .../download-center/download-center.service.ts | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/furniture-3d-system/.gitignore b/furniture-3d-system/.gitignore index 33f06d95..04c50df9 100644 --- a/furniture-3d-system/.gitignore +++ b/furniture-3d-system/.gitignore @@ -74,3 +74,6 @@ local-packages/npm-cache/cache/_logs/ # 脚本监控 Agent 本机凭据 agents/script-monitor/config.json + +# 下载中心本地运行时产物 +.download-center/ diff --git a/furniture-3d-system/src/server/services/download-center/download-center.service.ts b/furniture-3d-system/src/server/services/download-center/download-center.service.ts index 32fb8bc1..276ced5a 100644 --- a/furniture-3d-system/src/server/services/download-center/download-center.service.ts +++ b/furniture-3d-system/src/server/services/download-center/download-center.service.ts @@ -114,6 +114,12 @@ async function runTask(taskId: string) { params = {} } const result = await executor.run({ taskId: task.id, taskDir, params }) + // 任务在生成期间被删除/取消:丢弃产物,不再产出可下载文件 + const latest = await downloadTaskRepository.findById(taskId).catch(() => null) + if (!latest || latest.status !== 'processing') { + removeTaskDir(taskId) + return + } const filePath = path.join(taskDir, path.basename(result.fileName)) const fileSize = fs.existsSync(filePath) ? fs.statSync(filePath).size : 0 await downloadTaskRepository.update(task.id, { @@ -126,6 +132,10 @@ async function runTask(taskId: string) { finishedAt: now(), }) } catch (error) { + // 任务可能已在生成期间被删除:目录清掉、静默结束 + removeTaskDir(taskId) + const latest = await downloadTaskRepository.findById(taskId).catch(() => null) + if (!latest || latest.status !== 'processing') return const message = error instanceof Error ? error.message : String(error) console.error(`[download-center] 任务 ${taskId} 失败:`, message) await downloadTaskRepository.update(task.id, {