mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 05:36:19 +00:00
Remove jobs before deleting profile (#1107)
This commit is contained in:
parent
d8b61a0e33
commit
0b2a7c02c3
4 changed files with 12 additions and 9 deletions
|
@ -17,7 +17,6 @@
|
||||||
def init_logger(background=False):
|
def init_logger(background=False):
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
logging.getLogger('peewee').setLevel(logging.INFO)
|
logging.getLogger('peewee').setLevel(logging.INFO)
|
||||||
logging.getLogger('apscheduler').setLevel(logging.INFO)
|
|
||||||
logging.getLogger('PyQt5').setLevel(logging.INFO)
|
logging.getLogger('PyQt5').setLevel(logging.INFO)
|
||||||
|
|
||||||
# create logging format
|
# create logging format
|
||||||
|
|
|
@ -53,8 +53,7 @@ def set_timer_for_profile(self, profile_id):
|
||||||
# First stop and remove any existing timer for this profile
|
# First stop and remove any existing timer for this profile
|
||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
if profile_id in self.timers:
|
if profile_id in self.timers:
|
||||||
self.timers[profile_id]['qtt'].stop()
|
self.remove_job(profile_id)
|
||||||
del self.timers[profile_id]
|
|
||||||
|
|
||||||
# If no repo is set or only manual backups, just return without
|
# If no repo is set or only manual backups, just return without
|
||||||
# replacing the job we removed above.
|
# replacing the job we removed above.
|
||||||
|
@ -121,7 +120,6 @@ def reload_all_timers(self):
|
||||||
for profile in BackupProfileModel.select():
|
for profile in BackupProfileModel.select():
|
||||||
self.set_timer_for_profile(profile.id)
|
self.set_timer_for_profile(profile.id)
|
||||||
|
|
||||||
@property
|
|
||||||
def next_job(self):
|
def next_job(self):
|
||||||
next_job = now = dt.now()
|
next_job = now = dt.now()
|
||||||
next_profile = None
|
next_profile = None
|
||||||
|
@ -180,7 +178,7 @@ def create_backup(self, profile_id):
|
||||||
def notify(self, result):
|
def notify(self, result):
|
||||||
notifier = VortaNotifications.pick()
|
notifier = VortaNotifications.pick()
|
||||||
profile_name = result['params']['profile_name']
|
profile_name = result['params']['profile_name']
|
||||||
profile_id = result['params']['profile']
|
profile_id = result['params']['profile'].id
|
||||||
|
|
||||||
if result['returncode'] in [0, 1]:
|
if result['returncode'] in [0, 1]:
|
||||||
notifier.deliver(self.tr('Vorta Backup'),
|
notifier.deliver(self.tr('Vorta Backup'),
|
||||||
|
@ -229,3 +227,7 @@ def post_backup_tasks(self, profile_id):
|
||||||
self.app.jobs_manager.add_job(job)
|
self.app.jobs_manager.add_job(job)
|
||||||
|
|
||||||
logger.info('Finished background task for profile %s', profile.name)
|
logger.info('Finished background task for profile %s', profile.name)
|
||||||
|
|
||||||
|
def remove_job(self, profile_id):
|
||||||
|
self.timers[profile_id]['qtt'].stop()
|
||||||
|
del self.timers[profile_id]
|
||||||
|
|
|
@ -44,7 +44,8 @@ def on_user_click(self):
|
||||||
|
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
|
||||||
status = menu.addAction(self.app.scheduler.next_job)
|
next_task_time = self.app.scheduler.next_job()
|
||||||
|
status = menu.addAction(next_task_time)
|
||||||
status.setEnabled(False)
|
status.setEnabled(False)
|
||||||
|
|
||||||
if self.app.jobs_manager.is_worker_running():
|
if self.app.jobs_manager.is_worker_running():
|
||||||
|
@ -52,7 +53,7 @@ def on_user_click(self):
|
||||||
cancel_action = menu.addAction(self.tr('Cancel Backup'))
|
cancel_action = menu.addAction(self.tr('Cancel Backup'))
|
||||||
cancel_action.triggered.connect(self.app.backup_cancelled_event.emit)
|
cancel_action.triggered.connect(self.app.backup_cancelled_event.emit)
|
||||||
else:
|
else:
|
||||||
status.setText(self.tr('Next Task: %s') % self.app.scheduler.next_job)
|
status.setText(self.tr('Next Task: %s') % next_task_time)
|
||||||
profiles = BackupProfileModel.select()
|
profiles = BackupProfileModel.select()
|
||||||
if profiles.count() > 1:
|
if profiles.count() > 1:
|
||||||
profile_menu = menu.addMenu(self.tr('Backup Now'))
|
profile_menu = menu.addMenu(self.tr('Backup Now'))
|
||||||
|
|
|
@ -157,15 +157,16 @@ def profile_rename_action(self):
|
||||||
|
|
||||||
def profile_delete_action(self):
|
def profile_delete_action(self):
|
||||||
if self.profileSelector.count() > 1:
|
if self.profileSelector.count() > 1:
|
||||||
to_delete = BackupProfileModel.get(id=self.profileSelector.currentData())
|
to_delete_id = self.profileSelector.currentData()
|
||||||
|
to_delete = BackupProfileModel.get(id=to_delete_id)
|
||||||
|
|
||||||
# TODO: Remove pending background jobs
|
|
||||||
msg = self.tr("Are you sure you want to delete profile '{}'?".format(to_delete.name))
|
msg = self.tr("Are you sure you want to delete profile '{}'?".format(to_delete.name))
|
||||||
reply = QMessageBox.question(self, self.tr("Confirm deletion"),
|
reply = QMessageBox.question(self, self.tr("Confirm deletion"),
|
||||||
msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
||||||
|
|
||||||
if reply == QMessageBox.Yes:
|
if reply == QMessageBox.Yes:
|
||||||
to_delete.delete_instance(recursive=True)
|
to_delete.delete_instance(recursive=True)
|
||||||
|
self.app.scheduler.remove_job(to_delete_id) # Remove pending jobs
|
||||||
self.profileSelector.removeItem(self.profileSelector.currentIndex())
|
self.profileSelector.removeItem(self.profileSelector.currentIndex())
|
||||||
self.profile_select_action(0)
|
self.profile_select_action(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue