cleanupOutputFiles 清理任务的输出文件
(taskID string)
| 614 | |
| 615 | // cleanupOutputFiles 清理任务的输出文件 |
| 616 | func (tm *FileTaskManager) cleanupOutputFiles(taskID string) error { |
| 617 | tm.mu.RLock() |
| 618 | task, exists := tm.tasks[taskID] |
| 619 | tm.mu.RUnlock() |
| 620 | |
| 621 | if !exists { |
| 622 | return fmt.Errorf("task not found: %s", taskID) |
| 623 | } |
| 624 | |
| 625 | outputFile := filepath.Join(task.Options.OutputDir, taskID+".stdout") |
| 626 | errorFile := filepath.Join(task.Options.OutputDir, taskID+".stderr") |
| 627 | |
| 628 | // 清空文件内容 |
| 629 | if err := os.WriteFile(outputFile, []byte{}, 0644); err != nil { |
| 630 | return fmt.Errorf("failed to clear output file: %w", err) |
| 631 | } |
| 632 | |
| 633 | if err := os.WriteFile(errorFile, []byte{}, 0644); err != nil { |
| 634 | return fmt.Errorf("failed to clear error file: %w", err) |
| 635 | } |
| 636 | |
| 637 | return nil |
| 638 | } |