fix delete group issue #115

delete jobs run with group before delete group
pull/116/head
miraclesu 2018-11-07 23:11:30 +08:00
parent b2f14689de
commit fb788a4f74
1 changed files with 20 additions and 11 deletions

View File

@ -304,23 +304,32 @@ func (n *Node) addGroup(g *cronsun.Group) {
} }
func (n *Node) delGroup(id string) { func (n *Node) delGroup(id string) {
delete(n.groups, id) // delete job first
n.link.delGroup(id) defer n.link.delGroup(id)
defer delete(n.groups, id)
job, ok := n.jobs[id] jobLinks := n.link[id]
if len(jobLinks) == 0 {
return
}
for jID := range jobLinks {
job, ok := n.jobs[jID]
// 之前此任务没有在当前结点执行 // 之前此任务没有在当前结点执行
if !ok { if !ok {
return continue
} }
cmds := job.Cmds(n.ID, n.groups) cmds := job.Cmds(n.ID, n.groups)
if len(cmds) == 0 { if len(cmds) == 0 {
return continue
} }
for _, cmd := range cmds { for _, cmd := range cmds {
n.delCmd(cmd) n.delCmd(cmd)
} }
}
return return
} }