CleanupTask 清理任务相关文件
(taskID string)
| 329 | |
| 330 | // CleanupTask 清理任务相关文件 |
| 331 | func (tm *FileTaskManager) CleanupTask(taskID string) error { |
| 332 | tm.mu.Lock() |
| 333 | defer tm.mu.Unlock() |
| 334 | |
| 335 | task, exists := tm.tasks[taskID] |
| 336 | if !exists { |
| 337 | return fmt.Errorf("task not found: %s", taskID) |
| 338 | } |
| 339 | |
| 340 | // 删除输出文件 |
| 341 | outputFile := filepath.Join(task.Options.OutputDir, taskID+".stdout") |
| 342 | errorFile := filepath.Join(task.Options.OutputDir, taskID+".stderr") |
| 343 | |
| 344 | _ = os.Remove(outputFile) |
| 345 | _ = os.Remove(errorFile) |
| 346 | |
| 347 | // 删除任务信息 |
| 348 | delete(tm.tasks, taskID) |
| 349 | |
| 350 | // 删除任务文件 |
| 351 | taskFile := filepath.Join(tm.dataDir, taskID+".json") |
| 352 | _ = os.Remove(taskFile) |
| 353 | |
| 354 | return nil |
| 355 | } |
| 356 | |
| 357 | // buildCommand 构建命令 |
| 358 | func (tm *FileTaskManager) buildCommand(cmd string, opts *TaskOptions) string { |
no test coverage detected