diff --git a/src/vorta/application.py b/src/vorta/application.py index fac38440..921fe02f 100644 --- a/src/vorta/application.py +++ b/src/vorta/application.py @@ -175,6 +175,7 @@ class VortaApp(QtSingleApplication): borg_compat.set_version(result['data']['version'], result['data']['path']) self.main_window.miscTab.set_borg_details(borg_compat.version, borg_compat.path) self.main_window.repoTab.toggle_available_compression() + self.main_window.archiveTab.toggle_compact_button_visibility() self.scheduler.reload_all_timers() # Start timer after Borg version is set. else: self._alert_missing_borg() diff --git a/src/vorta/borg/compact.py b/src/vorta/borg/compact.py index 4f110a92..12bc160c 100644 --- a/src/vorta/borg/compact.py +++ b/src/vorta/borg/compact.py @@ -1,7 +1,7 @@ from typing import Any, Dict from vorta import config -from vorta.i18n import trans_late, translate +from vorta.i18n import translate from vorta.utils import borg_compat from .borg_job import BorgJob @@ -44,9 +44,7 @@ class BorgCompactJob(BorgJob): ret['ok'] = False # Set back to false, so we can do our own checks here. if not borg_compat.check('COMPACT_SUBCOMMAND'): - ret['ok'] = False - ret['message'] = trans_late('messages', 'This feature needs Borg 1.2.0 or higher.') - return ret + raise Exception('The compact action needs Borg >= 1.2.0') cmd = ['borg', '--info', '--log-json', 'compact', '--progress'] if borg_compat.check('V2'): diff --git a/src/vorta/views/archive_tab.py b/src/vorta/views/archive_tab.py index 71d74bb4..14a53cfc 100644 --- a/src/vorta/views/archive_tab.py +++ b/src/vorta/views/archive_tab.py @@ -35,6 +35,7 @@ from vorta.borg.umount import BorgUmountJob from vorta.i18n import translate from vorta.store.models import ArchiveModel, BackupProfileMixin from vorta.utils import ( + borg_compat, choose_file_dialog, find_best_unit_for_sizes, format_archive_name, @@ -83,6 +84,7 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin): self.tooltip_dict: Dict[QWidget, str] = {} self.tooltip_dict[self.bDiff] = self.bDiff.toolTip() self.tooltip_dict[self.bDelete] = self.bDelete.toolTip() + self.tooltip_dict[self.compactButton] = self.compactButton.toolTip() header = self.archiveTable.horizontalHeader() header.setVisible(True) @@ -981,3 +983,16 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin): self.populate_from_profile() else: self._toggle_all_buttons(True) + + def toggle_compact_button_visibility(self): + """ + Enable or disable the compact button depending on the Borg version. + This function runs once on startup, and everytime the profile is changed. + """ + if borg_compat.check("COMPACT_SUBCOMMAND"): + self.compactButton.setEnabled(True) + self.compactButton.setToolTip(self.tooltip_dict[self.compactButton]) + else: + self.compactButton.setEnabled(False) + tooltip = self.tooltip_dict[self.compactButton] + self.compactButton.setToolTip(tooltip + " " + self.tr("(This feature needs Borg 1.2.0 or higher)")) diff --git a/src/vorta/views/main_window.py b/src/vorta/views/main_window.py index ca0c2426..fab20dfe 100644 --- a/src/vorta/views/main_window.py +++ b/src/vorta/views/main_window.py @@ -167,6 +167,7 @@ class MainWindow(MainWindowBase, MainWindowUI): SettingsModel.update({SettingsModel.str_value: self.current_profile.id}).where( SettingsModel.key == 'previous_profile_id' ).execute() + self.archiveTab.toggle_compact_button_visibility() def profile_rename_action(self): window = EditProfileWindow(rename_existing_id=self.profileSelector.currentData())