Remove jobs if scheduler setting is changed. (#1105)

This commit is contained in:
Manu 2021-11-15 15:02:27 +04:00 committed by GitHub
parent 228e580def
commit d8b61a0e33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -38,7 +38,7 @@ class VortaScheduler(QtCore.QObject):
"""
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.
@ -47,19 +47,24 @@ class VortaScheduler(QtCore.QObject):
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',