(task core.Executable, taskType tasktype.TaskType, storageName, path, webhook string)
| 68 | } |
| 69 | |
| 70 | func (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 创建直链下载任务 |
| 89 | func (f *TaskFactory) createDirectLinksTask(taskID string, createdAt time.Time, req *CreateTaskRequest, stor storage.Storage) (*CreateTaskResponse, error) { |
no test coverage detected