fix(download-center): 生成中删除任务时丢弃产物,并忽略本地运行目录
This commit is contained in:
parent
8a95dbcbf0
commit
fa17ffa9a8
3
furniture-3d-system/.gitignore
vendored
3
furniture-3d-system/.gitignore
vendored
@ -74,3 +74,6 @@ local-packages/npm-cache/cache/_logs/
|
||||
|
||||
# 脚本监控 Agent 本机凭据
|
||||
agents/script-monitor/config.json
|
||||
|
||||
# 下载中心本地运行时产物
|
||||
.download-center/
|
||||
|
||||
@ -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, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user