happier del

master
Bel LaPointe 2021-09-28 15:06:53 -06:00
parent 7db42cf5f0
commit 3d6fae2dab
1 changed files with 5 additions and 13 deletions

View File

@ -216,20 +216,12 @@ func (s *Scheduler) Add(j *Job) error {
func (s *Scheduler) Remove(j *Job) error { func (s *Scheduler) Remove(j *Job) error {
logb.Debugf("[sched] rm: %+v", j) logb.Debugf("[sched] rm: %+v", j)
entryID, ok := s.getEntry(j) if entryID, ok := s.getEntry(j); ok {
if !ok { s.cron.Remove(entryID)
return ErrJobNotFound
} }
was := len(s.cron.Entries()) config.Store.Set(j.Name, nil, ns.Jobs...)
s.cron.Remove(entryID) config.Store.Set(j.Name, nil, ns.JobsRaw...)
is := len(s.cron.Entries()) return nil
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...)
} }
func (s *Scheduler) getEntry(j *Job) (cron.EntryID, bool) { func (s *Scheduler) getEntry(j *Job) (cron.EntryID, bool) {