2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00

fix: 等待中的任务显示为运行中

This commit is contained in:
耗子
2024-07-13 03:25:55 +08:00
parent 1e081fcdf2
commit fee0fcb998
3 changed files with 17 additions and 19 deletions

View File

@@ -3,7 +3,6 @@ package services
import (
"sync"
"github.com/goravel/framework/database/orm"
"github.com/goravel/framework/facades"
"github.com/TheTNB/panel/app/jobs"
@@ -20,9 +19,7 @@ func NewTaskImpl() *TaskImpl {
}
func (r *TaskImpl) Process(taskID uint) error {
if err := r.markAsRunning(taskID); err != nil {
return err
}
taskMap.Store(taskID, true)
return facades.Queue().Job(&jobs.ProcessTask{}, []any{taskID}).Dispatch()
}
@@ -43,16 +40,3 @@ func (r *TaskImpl) DispatchWaiting() error {
return nil
}
func (r *TaskImpl) markAsRunning(taskID uint) error {
task := models.Task{
Model: orm.Model{ID: taskID},
Status: models.TaskStatusRunning,
}
if _, err := facades.Orm().Query().Where("id", taskID).Update(&task); err != nil {
return err
}
taskMap.Store(taskID, true)
return nil
}