MCPcopy Create free account
hub / github.com/krau/SaveAny-Bot / registerAndEnqueueTask

Method registerAndEnqueueTask

api/factory.go:70–86  ·  view source on GitHub ↗
(task core.Executable, taskType tasktype.TaskType, storageName, path, webhook string)

Source from the content-addressed store, hash-verified

68}
69
70func (f *TaskFactory) registerAndEnqueueTask(task core.Executable, taskType tasktype.TaskType, storageName, path, webhook string) error {
71 taskID := task.TaskID()
72 info := RegisterTask(taskID, string(taskType), storageName, path, task.Title(), webhook)
73
74 // Inject the progress sink into the context so the task's Emit calls update
75 // the API store (and fire the webhook on terminal states) without the task
76 // knowing about the API.
77 taskCtx := taskevent.WithSink(f.ctx, info)
78
79 err := core.AddTask(taskCtx, task)
80 if err != nil {
81 DeleteTask(taskID)
82 return fmt.Errorf("failed to add task: %w", err)
83 }
84
85 return nil
86}
87
88// createDirectLinksTask 创建直链下载任务
89func (f *TaskFactory) createDirectLinksTask(taskID string, createdAt time.Time, req *CreateTaskRequest, stor storage.Storage) (*CreateTaskResponse, error) {

Callers 7

createDirectLinksTaskMethod · 0.95
createYTDLPTaskMethod · 0.95
createAria2TaskMethod · 0.95
createParsedTaskMethod · 0.95
createTGFilesTaskMethod · 0.95
createTPHPicsTaskMethod · 0.95
createTransferTaskMethod · 0.95

Calls 6

WithSinkFunction · 0.92
AddTaskFunction · 0.92
RegisterTaskFunction · 0.85
DeleteTaskFunction · 0.85
TaskIDMethod · 0.65
TitleMethod · 0.65

Tested by

no test coverage detected