Skip to content
Merged
1 change: 1 addition & 0 deletions src/vorta/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def set_borg_details_result(self, result):
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()
Expand Down
6 changes: 2 additions & 4 deletions src/vorta/borg/compact.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -44,9 +44,7 @@ def prepare(cls, profile):
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'):
Expand Down
15 changes: 15 additions & 0 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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,
Expand Down Expand Up @@ -83,6 +84,7 @@ def __init__(self, parent=None, app=None):
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)
Expand Down Expand Up @@ -981,3 +983,16 @@ def rename_result(self, result):
self.populate_from_profile()
else:
self._toggle_all_buttons(True)

def toggle_compact_button_visibility(self):
Comment thread
real-yfprojects marked this conversation as resolved.
Comment thread
diivi marked this conversation as resolved.
"""
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)"))
1 change: 1 addition & 0 deletions src/vorta/views/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def profile_select_action(self, index):
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())
Expand Down