chore: trt to fix restore bool val #70
This commit is contained in:
@@ -370,7 +370,7 @@ func (es *ExecutorService) HandleTaskRetry(task *models.Task, req *executor.Exec
|
||||
|
||||
es.scheduler.EnqueueDelayed(time.Duration(task.RetryInterval)*time.Second, func() *executor.ExecutionRequest {
|
||||
latestTask := es.taskService.GetTaskByID(task.ID)
|
||||
if latestTask == nil || !latestTask.Enabled {
|
||||
if latestTask == nil || !utils.DerefBool(latestTask.Enabled, true) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ func (es *ExecutorService) loadCronTasks() {
|
||||
tasks := es.taskService.GetTasks()
|
||||
count := 0
|
||||
for _, task := range tasks {
|
||||
if !task.Enabled {
|
||||
if !utils.DerefBool(task.Enabled, true) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -875,7 +875,7 @@ func (es *ExecutorService) ExecuteRemoteForScheduler(task *models.Task, logID st
|
||||
if res.Error != nil || res.RowsAffected == 0 {
|
||||
return nil, fmt.Errorf("Agent #%s 不存在", agentID)
|
||||
}
|
||||
if !agent.Enabled {
|
||||
if !utils.DerefBool(agent.Enabled, true) {
|
||||
return nil, fmt.Errorf("Agent #%s 已禁用", agentID)
|
||||
}
|
||||
if es.agentWSManager == nil {
|
||||
|
||||
@@ -311,7 +311,7 @@ func ParseRepoScriptsAndAddCron(es *ExecutorService, taskID string, logWriter io
|
||||
}
|
||||
database.DB.Save(&existing)
|
||||
|
||||
if existing.Enabled && es != nil {
|
||||
if utils.DerefBool(existing.Enabled, true) && es != nil {
|
||||
es.AddCronTask(&existing)
|
||||
}
|
||||
log("[更新] 任务: %s (%s)", taskName, filename)
|
||||
@@ -329,7 +329,7 @@ func ParseRepoScriptsAndAddCron(es *ExecutorService, taskID string, logWriter io
|
||||
Languages: repoTask.Languages,
|
||||
Timeout: repoTask.Timeout,
|
||||
Config: models.BigText(defaultTaskConfig),
|
||||
Enabled: true,
|
||||
Enabled: utils.BoolPtr(true),
|
||||
WorkDir: displayWorkDir,
|
||||
SourceID: sourceID,
|
||||
RepoTaskID: repoTask.ID,
|
||||
|
||||
@@ -44,7 +44,7 @@ func (ts *TaskService) CreateTask(name, command, schedule string, timeout int, w
|
||||
Envs: models.BigText(envs),
|
||||
Languages: languages,
|
||||
AgentID: agentID,
|
||||
Enabled: true,
|
||||
Enabled: utils.BoolPtr(true),
|
||||
RetryCount: retryCount,
|
||||
RetryInterval: retryInterval,
|
||||
RandomRange: randomRange,
|
||||
@@ -113,7 +113,7 @@ func (ts *TaskService) UpdateTask(id string, name, command, schedule string, tim
|
||||
task.WorkDir = workDir
|
||||
task.CleanConfig = cleanConfig
|
||||
task.Envs = models.BigText(envs)
|
||||
task.Enabled = enabled
|
||||
task.Enabled = &enabled
|
||||
task.AgentID = agentID
|
||||
task.Languages = languages
|
||||
task.Config = models.BigText(config)
|
||||
|
||||
Reference in New Issue
Block a user