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 {
if !ok {
return return
} }
cmds := job.Cmds(n.ID, n.groups) for jID := range jobLinks {
if len(cmds) == 0 { job, ok := n.jobs[jID]
return // 之前此任务没有在当前结点执行
if !ok {
continue
}
cmds := job.Cmds(n.ID, n.groups)
if len(cmds) == 0 {
continue
}
for _, cmd := range cmds {
n.delCmd(cmd)
}
} }
for _, cmd := range cmds {
n.delCmd(cmd)
}
return return
} }