From 3d6fae2dab1252606a0555df814384456f5329f4 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 28 Sep 2021 15:06:53 -0600 Subject: [PATCH] happier del --- scheduler/scheduler.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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) {