Restored 'cancel' functionality
Now user can actually cancel a backup/restore.
This commit is contained in:
parent
14ebf9dc6d
commit
7fd0c58303
@ -55,7 +55,6 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
|||||||
self.backup_settings = QtCore.QSettings()
|
self.backup_settings = QtCore.QSettings()
|
||||||
|
|
||||||
self.selected_vms = []
|
self.selected_vms = []
|
||||||
self.tmpdir_to_remove = None
|
|
||||||
self.canceled = False
|
self.canceled = False
|
||||||
self.thread_monitor = None
|
self.thread_monitor = None
|
||||||
|
|
||||||
@ -300,16 +299,10 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
|||||||
|
|
||||||
if not self.thread_monitor.success:
|
if not self.thread_monitor.success:
|
||||||
if self.canceled:
|
if self.canceled:
|
||||||
self.progress_status.setText(self.tr("Backup aborted."))
|
self.progress_status.setText(
|
||||||
if self.tmpdir_to_remove:
|
self.tr(
|
||||||
if QtGui.QMessageBox.warning(
|
"Backup aborted. "
|
||||||
None, self.tr("Backup aborted"),
|
"Temporary file may be left at backup location."))
|
||||||
self.tr(
|
|
||||||
"Do you want to remove temporary files "
|
|
||||||
"from %s?") % self.tmpdir_to_remove,
|
|
||||||
QtGui.QMessageBox.Yes,
|
|
||||||
QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes:
|
|
||||||
shutil.rmtree(self.tmpdir_to_remove)
|
|
||||||
else:
|
else:
|
||||||
self.progress_status.setText(self.tr("Backup error."))
|
self.progress_status.setText(self.tr("Backup error."))
|
||||||
QtGui.QMessageBox.warning(
|
QtGui.QMessageBox.warning(
|
||||||
@ -333,12 +326,14 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
|||||||
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
# cancel clicked while the backup is in progress.
|
|
||||||
# calling kill on tar.
|
|
||||||
if self.currentPage() is self.commit_page:
|
if self.currentPage() is self.commit_page:
|
||||||
pass # TODO: this does nothing
|
self.canceled = True
|
||||||
# if backup.backup_cancel():
|
self.qvm_collection.qubesd_call(
|
||||||
# self.button(self.CancelButton).setDisabled(True)
|
'dom0', 'admin.backup.Cancel',
|
||||||
|
backup_utils.get_profile_name(True))
|
||||||
|
self.progress_bar.setMaximum(100)
|
||||||
|
self.progress_bar.setValue(0)
|
||||||
|
self.button(self.CancelButton).setDisabled(True)
|
||||||
else:
|
else:
|
||||||
self.done(0)
|
self.done(0)
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
self.func_output = []
|
self.func_output = []
|
||||||
self.feedback_queue = Queue()
|
self.feedback_queue = Queue()
|
||||||
self.canceled = False
|
self.canceled = False
|
||||||
self.tmpdir_to_remove = None
|
|
||||||
self.error_detected = Event()
|
self.error_detected = Event()
|
||||||
self.thread_monitor = None
|
self.thread_monitor = None
|
||||||
self.backup_restore = None
|
self.backup_restore = None
|
||||||
@ -154,7 +153,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
|
|
||||||
except backup.BackupCanceledError as ex:
|
except backup.BackupCanceledError as ex:
|
||||||
self.canceled = True
|
self.canceled = True
|
||||||
self.tmpdir_to_remove = ex.tmpdir
|
|
||||||
err_msg.append(str(ex))
|
err_msg.append(str(ex))
|
||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
err_msg.append(str(ex))
|
err_msg.append(str(ex))
|
||||||
@ -227,17 +225,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if not self.thread_monitor.success:
|
if not self.thread_monitor.success:
|
||||||
if self.canceled:
|
if not self.canceled:
|
||||||
if self.tmpdir_to_remove and \
|
|
||||||
QtGui.QMessageBox.warning(
|
|
||||||
None,
|
|
||||||
self.tr("Restore aborted"),
|
|
||||||
self.tr("Do you want to remove temporary files "
|
|
||||||
"from %s?") % self.tmpdir_to_remove,
|
|
||||||
QtGui.QMessageBox.Yes,
|
|
||||||
QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes:
|
|
||||||
shutil.rmtree(self.tmpdir_to_remove)
|
|
||||||
else:
|
|
||||||
QtGui.QMessageBox.warning(
|
QtGui.QMessageBox.warning(
|
||||||
None,
|
None,
|
||||||
self.tr("Backup error!"),
|
self.tr("Backup error!"),
|
||||||
@ -268,12 +256,12 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def reject(self): # TODO: probably not working too
|
def reject(self):
|
||||||
if self.currentPage() is self.commit_page:
|
if self.currentPage() is self.commit_page:
|
||||||
if self.backup_restore.canceled:
|
self.backup_restore.canceled = True
|
||||||
self.append_output('<font color="red">{0}</font>'.format(
|
self.append_output('<font color="red">{0}</font>'.format(
|
||||||
self.tr("Aborting the operation...")))
|
self.tr("Aborting the operation...")))
|
||||||
self.button(self.CancelButton).setDisabled(True)
|
self.button(self.CancelButton).setDisabled(True)
|
||||||
else:
|
else:
|
||||||
self.done(0)
|
self.done(0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user