queue sync calls

This commit is contained in:
André Roth
2024-06-08 12:27:59 +02:00
parent efc5573b8e
commit 3e1485faf5
3 changed files with 24 additions and 3 deletions

View File

@@ -164,9 +164,17 @@ func maybeRunTaskInBackground(c *gin.Context, name string, resources []string, p
c.JSON(202, task)
} else {
log.Debug().Msg("Executing task synchronously")
out := context.Progress()
detail := task.Detail{}
retValue, err := proc(out, &detail)
task, conflictErr := runTaskInBackground(name, resources, proc)
if conflictErr != nil {
AbortWithJSONError(c, 409, conflictErr)
return
}
// wait for task to finish
context.TaskList().WaitForTaskByID(task.ID)
retValue, _ := context.TaskList().GetTaskReturnValueByID(task.ID)
err, _ := context.TaskList().GetTaskErrorByID(task.ID)
if err != nil {
AbortWithJSONError(c, retValue.Code, err)
return