MCPcopy Index your code
hub / github.com/aptly-dev/aptly / DeleteTaskByID

Method DeleteTaskByID

task/list.go:124–141  ·  view source on GitHub ↗

DeleteTaskByID deletes given task from list. Only finished tasks can be deleted.

(ID int)

Source from the content-addressed store, hash-verified

122// DeleteTaskByID deletes given task from list. Only finished
123// tasks can be deleted.
124func (list *List) DeleteTaskByID(ID int) (Task, error) {
125 list.Lock()
126 defer list.Unlock()
127
128 tasks := list.tasks
129 for i, task := range tasks {
130 if task.ID == ID {
131 if task.State == SUCCEEDED || task.State == FAILED {
132 list.tasks = append(tasks[:i], tasks[i+1:]...)
133 return *task, nil
134 }
135
136 return *task, fmt.Errorf("task with id %v is still in state=%d", ID, task.State)
137 }
138 }
139
140 return Task{}, fmt.Errorf("could not find task with id %v", ID)
141}
142
143// GetTaskByID returns task with given id
144func (list *List) GetTaskByID(ID int) (Task, error) {

Callers 3

TestListMethod · 0.95
maybeRunTaskInBackgroundFunction · 0.80
apiTasksDeleteFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestListMethod · 0.76