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, {