diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 5bc6c0e..11f6c8a 100755 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -216,20 +216,12 @@ func (s *Scheduler) Add(j *Job) error { func (s *Scheduler) Remove(j *Job) error { logb.Debugf("[sched] rm: %+v", j) - entryID, ok := s.getEntry(j) - if !ok { - return ErrJobNotFound + if entryID, ok := s.getEntry(j); ok { + s.cron.Remove(entryID) } - was := len(s.cron.Entries()) - s.cron.Remove(entryID) - is := len(s.cron.Entries()) - if was == is { - return ErrJobNotFound - } - if err := config.Store.Set(j.Name, nil, ns.Jobs...); err != nil { - return err - } - return config.Store.Set(j.Name, nil, ns.JobsRaw...) + config.Store.Set(j.Name, nil, ns.Jobs...) + config.Store.Set(j.Name, nil, ns.JobsRaw...) + return nil } func (s *Scheduler) getEntry(j *Job) (cron.EntryID, bool) {