MCPcopy Create free account
hub / github.com/astercloud/aster / loadTasks

Method loadTasks

pkg/tools/builtin/task_manager.go:481–507  ·  view source on GitHub ↗

loadTasks 从文件加载任务

()

Source from the content-addressed store, hash-verified

479
480// loadTasks 从文件加载任务
481func (tm *FileTaskManager) loadTasks() error {
482 files, err := os.ReadDir(tm.dataDir)
483 if err != nil {
484 return fmt.Errorf("failed to read data directory: %w", err)
485 }
486
487 for _, file := range files {
488 if filepath.Ext(file.Name()) != ".json" {
489 continue
490 }
491
492 taskFile := filepath.Join(tm.dataDir, file.Name())
493 data, err := os.ReadFile(taskFile)
494 if err != nil {
495 continue
496 }
497
498 var task TaskInfo
499 if err := json.Unmarshal(data, &task); err != nil {
500 continue
501 }
502
503 tm.tasks[task.ID] = &task
504 }
505
506 return nil
507}
508
509// cleanupRoutine 清理协程
510func (tm *FileTaskManager) cleanupRoutine() {

Callers 1

NewFileTaskManagerFunction · 0.95

Calls 3

NameMethod · 0.65
JoinMethod · 0.45
ReadFileMethod · 0.45

Tested by

no test coverage detected