Browse Source

fix: 解决编辑已停止计划任务导致任务执行的问题 (#1218)

pull/1219/head
ssongliu 2 years ago committed by GitHub
parent
commit
01ed60fcb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      backend/app/service/cornjob.go

15
backend/app/service/cornjob.go

@ -221,16 +221,20 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
if err != nil {
return constant.ErrRecordNotFound
}
upMap := make(map[string]interface{})
cronjob.EntryID = cronModel.EntryID
cronjob.Type = cronModel.Type
cronjob.Spec = loadSpec(cronjob)
newEntryID, err := u.StartJob(&cronjob)
if err != nil {
return err
if cronModel.Status == constant.StatusEnable {
newEntryID, err := u.StartJob(&cronjob)
if err != nil {
return err
}
upMap["entry_id"] = newEntryID
} else {
global.Cron.Remove(cron.EntryID(cronjob.EntryID))
}
upMap := make(map[string]interface{})
upMap["entry_id"] = newEntryID
upMap["name"] = req.Name
upMap["spec"] = cronjob.Spec
upMap["script"] = req.Script
@ -239,6 +243,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
upMap["day"] = req.Day
upMap["hour"] = req.Hour
upMap["minute"] = req.Minute
upMap["second"] = req.Second
upMap["website"] = req.Website
upMap["exclusion_rules"] = req.ExclusionRules
upMap["db_name"] = req.DBName

Loading…
Cancel
Save