This commit is contained in:
Baobhan Sith
2025-05-16 20:36:20 +08:00
parent 3ccaca7144
commit ecf7b959ec
6 changed files with 56 additions and 28 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ export const downloadDirectory = async (req: Request, res: Response): Promise<vo
console.error(`Error reading file stream ${currentRemotePath}:`, streamErr);
// 如何通知 Archiver 或中断? Archiver 的 error 事件应该会捕获?
if (!archive.destroyed) { // 检查 archive 是否已被销毁
archive.abort(); // 尝试止 archive
archive.abort(); // 尝试止 archive
}
});
}
@@ -56,7 +56,7 @@ export class TransfersService {
// 异步启动传输,不阻塞当前请求
this.processTransferTask(taskId, abortController.signal).catch(error => { // +++ 传递 signal +++
console.error(`[TransfersService] Error processing task ${taskId} in background:`, error);
// 如果不是因为止操作导致的错误,则更新状态
// 如果不是因为止操作导致的错误,则更新状态
if (error.name !== 'AbortError') {
this.updateOverallTaskStatus(taskId, 'failed', `Background processing error: ${error.message}`);
}
@@ -75,7 +75,7 @@ export class TransfersService {
const abortController = this.taskAbortControllers.get(taskId);
if (abortController) {
console.info(`[TransfersService] Cancelling task ${taskId}.`);
abortController.abort(); // 触发止信号
abortController.abort(); // 触发止信号
// 更新主任务状态
// 假设 'cancelling' 和 'cancelled' 是有效的状态