Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,14 @@ def on_selection_change(self, selected=None, deselected=None):
if not self.repoactions_enabled:
reason = self.tr("(borg already running)")

# toggle delete button
# Disable the delete and refresh buttons if no archive is selected
if self.repoactions_enabled and len(indexes) > 0:
self.bDelete.setEnabled(True)
self.bRefreshArchive.setEnabled(True)
self.bDelete.setToolTip(self.tooltip_dict.get(self.bDelete, ""))
else:
self.bDelete.setEnabled(False)
self.bRefreshArchive.setEnabled(False)
tooltip = self.tooltip_dict[self.bDelete]
self.bDelete.setToolTip(tooltip + " " + reason or self.tr("(Select minimum one archive)"))

Expand All @@ -353,7 +355,8 @@ def on_selection_change(self, selected=None, deselected=None):

if self.repoactions_enabled and len(indexes) == 1:
# Enable archive actions
self.fArchiveActions.setEnabled(True)
for widget in [self.bMountArchive, self.bExtract, self.bRename]:
widget.setEnabled(True)

for index in range(layout.count()):
widget = layout.itemAt(index).widget()
Expand All @@ -365,14 +368,11 @@ def on_selection_change(self, selected=None, deselected=None):
reason = reason or self.tr("(Select exactly one archive)")

# too few or too many selected.
self.fArchiveActions.setEnabled(False)

for index in range(layout.count()):
widget = layout.itemAt(index).widget()
for widget in [self.bMountArchive, self.bExtract, self.bRename]:
tooltip = widget.toolTip()

tooltip = self.tooltip_dict.setdefault(widget, tooltip)
widget.setToolTip(tooltip + " " + reason)
widget.setEnabled(False)

# special treatment for dynamic mount/unmount button.
self.bmountarchive_refresh()
Expand Down Expand Up @@ -488,15 +488,28 @@ def list_result(self, result):
self.populate_from_profile()

def refresh_archive_info(self):
archive_name = self.selected_archive_name()
if archive_name is not None:
params = BorgInfoArchiveJob.prepare(self.profile(), archive_name)
if params['ok']:
job = BorgInfoArchiveJob(params['cmd'], params, self.profile().repo.id)
job.updated.connect(self._set_status)
job.result.connect(self.info_result)
self._toggle_all_buttons(False)
self.app.jobs_manager.add_job(job)
selected_archives = self.archiveTable.selectionModel().selectedRows()
profile = self.profile()

name_list = []
for index in selected_archives:
name_list.append(self.archiveTable.item(index.row(), 4).text())

archive_list = (
profile.repo.archives.select().where(ArchiveModel.name << name_list).order_by(ArchiveModel.time.desc())
)

archive_names = [archive.name for archive in archive_list]

for archive_name in archive_names:
if archive_name is not None:
params = BorgInfoArchiveJob.prepare(self.profile(), archive_name)
if params['ok']:
job = BorgInfoArchiveJob(params['cmd'], params, self.profile().repo.id)
job.updated.connect(self._set_status)
job.result.connect(self.info_result)
self._toggle_all_buttons(False)
self.app.jobs_manager.add_job(job)

def info_result(self, result):
self._toggle_all_buttons(True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will enable the buttons again although the other info jobs are still running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should I connect just the last job's result to this function?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, theoretically you don't know which job finishes first. Did you try to run the current code? I would think that only one borg jobs succeeds because of the repo lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I tried running it (I attached a GIF above).

Copy link
Contributor Author

@diivi diivi Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I didn't attach the GIF. Here,
Peek 2023-06-15 02-22

They do blink, but all jobs are succeeding right?

Expand Down