cleanupCompletedTasks 清理完成的任务
()
| 521 | |
| 522 | // cleanupCompletedTasks 清理完成的任务 |
| 523 | func (tm *FileTaskManager) cleanupCompletedTasks() { |
| 524 | tm.mu.Lock() |
| 525 | defer tm.mu.Unlock() |
| 526 | |
| 527 | for _, task := range tm.tasks { |
| 528 | if task.Status == "completed" || task.Status == "failed" { |
| 529 | // 清理超过1小时的已完成任务 |
| 530 | if time.Since(*task.EndTime) > time.Hour { |
| 531 | delete(tm.tasks, task.ID) |
| 532 | |
| 533 | taskFile := filepath.Join(tm.dataDir, task.ID+".json") |
| 534 | _ = os.Remove(taskFile) |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | // getSignalNumber 获取信号编号 |
| 541 | func (tm *FileTaskManager) getSignalNumber(signal string) int { |
no test coverage detected