Skip to content

Commit

Permalink
Remove jobs if scheduler setting is changed. (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
m3nu authored Nov 15, 2021
1 parent 228e580 commit d8b61a0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/vorta/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def set_timer_for_profile(self, profile_id):
"""
Set a timer for next scheduled backup run of this profile.
Does nothing if set to manual backups or no repo is assigned.
Removes existing jobs if set to manual only or no repo is assigned.
Else will look for previous scheduled backups and catch up if
schedule_make_up_missed is enabled.
Expand All @@ -47,19 +47,24 @@ def set_timer_for_profile(self, profile_id):
next suitable backup time.
"""
profile = BackupProfileModel.get_or_none(id=profile_id)
if profile is None \
or profile.repo is None \
or profile.schedule_mode == 'off':
if profile is None: # profile doesn't exist any more.
return

logger.info('Setting new timer for profile %s', profile_id)
# First stop and remove any existing timer for this profile
self.lock.acquire()

# Stop and remove any existing timer for this profile
if profile_id in self.timers:
self.timers[profile_id]['qtt'].stop()
del self.timers[profile_id]

# If no repo is set or only manual backups, just return without
# replacing the job we removed above.
if profile.repo is None or profile.schedule_mode == 'off':
logger.debug('Scheduler for profile %s is disabled.', profile_id)
self.lock.release()
return

logger.info('Setting timer for profile %s', profile_id)

last_run_log = EventLogModel.select().where(
EventLogModel.subcommand == 'create',
EventLogModel.category == 'scheduled',
Expand Down

0 comments on commit d8b61a0

Please sign in to comment.