diff --git a/qubesmanager/backup.py b/qubesmanager/backup.py index 202a967..7dad50d 100644 --- a/qubesmanager/backup.py +++ b/qubesmanager/backup.py @@ -55,7 +55,6 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard): self.backup_settings = QtCore.QSettings() self.selected_vms = [] - self.tmpdir_to_remove = None self.canceled = False self.thread_monitor = None @@ -300,16 +299,10 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard): if not self.thread_monitor.success: if self.canceled: - self.progress_status.setText(self.tr("Backup aborted.")) - if self.tmpdir_to_remove: - if QtGui.QMessageBox.warning( - None, self.tr("Backup 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) + self.progress_status.setText( + self.tr( + "Backup aborted. " + "Temporary file may be left at backup location.")) else: self.progress_status.setText(self.tr("Backup error.")) QtGui.QMessageBox.warning( @@ -333,12 +326,14 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard): signal.signal(signal.SIGCHLD, old_sigchld_handler) def reject(self): - # cancel clicked while the backup is in progress. - # calling kill on tar. if self.currentPage() is self.commit_page: - pass # TODO: this does nothing - # if backup.backup_cancel(): - # self.button(self.CancelButton).setDisabled(True) + self.canceled = True + self.qvm_collection.qubesd_call( + '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: self.done(0) diff --git a/qubesmanager/restore.py b/qubesmanager/restore.py index 1278624..93950a2 100644 --- a/qubesmanager/restore.py +++ b/qubesmanager/restore.py @@ -57,7 +57,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): self.func_output = [] self.feedback_queue = Queue() self.canceled = False - self.tmpdir_to_remove = None self.error_detected = Event() self.thread_monitor = None self.backup_restore = None @@ -154,7 +153,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): except backup.BackupCanceledError as ex: self.canceled = True - self.tmpdir_to_remove = ex.tmpdir err_msg.append(str(ex)) except Exception as ex: # pylint: disable=broad-except err_msg.append(str(ex)) @@ -227,17 +225,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): pass if not self.thread_monitor.success: - if 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: + if not self.canceled: QtGui.QMessageBox.warning( None, self.tr("Backup error!"), @@ -268,12 +256,12 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): return False return True - def reject(self): # TODO: probably not working too + def reject(self): if self.currentPage() is self.commit_page: - if self.backup_restore.canceled: - self.append_output('{0}'.format( - self.tr("Aborting the operation..."))) - self.button(self.CancelButton).setDisabled(True) + self.backup_restore.canceled = True + self.append_output('{0}'.format( + self.tr("Aborting the operation..."))) + self.button(self.CancelButton).setDisabled(True) else: self.done(0)