Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix task edit problem when status is running #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/controllers/task.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package controllers

import (
"strconv"
"strings"
"time"

"github.com/astaxie/beego"
libcron "github.com/lisijie/cron"
"github.com/lisijie/webcron/app/jobs"
"github.com/lisijie/webcron/app/libs"
"github.com/lisijie/webcron/app/models"
"strconv"
"strings"
"time"
)

type TaskController struct {
Expand Down Expand Up @@ -163,7 +164,18 @@ func (this *TaskController) Edit() {
if err := task.Update(); err != nil {
this.ajaxMsg(err.Error(), MSG_ERR)
}

if task.Status == 1 {
jobs.RemoveJob(id)
job, err := jobs.NewJobFromTask(task)
if err != nil {
this.ajaxMsg(err.Error(), MSG_ERR)
}
if jobs.AddJob(task.CronSpec, job) {
this.ajaxMsg("", MSG_OK)
} else {
this.ajaxMsg("编辑后刷新任务失败", MSG_ERR)
}
}
this.ajaxMsg("", MSG_OK)
}

Expand Down