Disable compact button for older borg versions. By @diivi (#1727)

This commit is contained in:
Divyansh Singh 2023-06-24 00:50:23 +05:30 committed by GitHub
parent c56c6700ca
commit f76195e47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -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()

View File

@ -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'):

View File

@ -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)"))

View File

@ -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())