mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
More informative return value for task.Process
This commit is contained in:
+13
-2
@@ -105,6 +105,17 @@ func (list *List) GetTaskDetailByID(ID int) (interface{}, error) {
|
||||
return detail, nil
|
||||
}
|
||||
|
||||
// GetTaskReturnValueByID returns process return value of task with given id
|
||||
func (list *List) GetTaskReturnValueByID(ID int) (*ProcessReturnValue, error) {
|
||||
task, err := list.GetTaskByID(ID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return task.processReturnValue, nil
|
||||
}
|
||||
|
||||
// RunTaskInBackground creates task and runs it in background. It won't be run and an error
|
||||
// returned if there are running tasks which are using needed resources already.
|
||||
func (list *List) RunTaskInBackground(name string, resources []string, process Process) (Task, *ResourceConflictError) {
|
||||
@@ -139,11 +150,11 @@ func (list *List) RunTaskInBackground(name string, resources []string, process P
|
||||
}
|
||||
list.Unlock()
|
||||
|
||||
retCode, err := process(aptly.Progress(task.output), task.detail)
|
||||
retValue, err := process(aptly.Progress(task.output), task.detail)
|
||||
|
||||
list.Lock()
|
||||
{
|
||||
task.processReturnCode = retCode
|
||||
task.processReturnValue = retValue
|
||||
if err != nil {
|
||||
task.output.Printf("Task failed with error: %v", err)
|
||||
task.State = FAILED
|
||||
|
||||
Reference in New Issue
Block a user