Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh multiple archives #1723

Merged
merged 15 commits into from
Jul 5, 2023
Merged
41 changes: 30 additions & 11 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ def on_selection_change(self, selected=None, deselected=None):
# toggle delete button
diivi marked this conversation as resolved.
Show resolved Hide resolved
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, ""))
diivi marked this conversation as resolved.
Show resolved Hide resolved
else:
self.bDelete.setEnabled(False)
self.bRefreshArchive.setEnabled(False)
diivi marked this conversation as resolved.
Show resolved Hide resolved
tooltip = self.tooltip_dict[self.bDelete]
self.bDelete.setToolTip(tooltip + " " + reason or self.tr("(Select minimum one archive)"))

Expand Down Expand Up @@ -365,14 +367,18 @@ 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)
self.bMountArchive.setEnabled(False)
self.bExtract.setEnabled(False)
self.bRename.setEnabled(False)

for index in range(layout.count()):
widget = layout.itemAt(index).widget()
tooltip = widget.toolTip()

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

if 'Refresh' not in tooltip:
diivi marked this conversation as resolved.
Show resolved Hide resolved
widget.setToolTip(tooltip + " " + reason)

# special treatment for dynamic mount/unmount button.
self.bmountarchive_refresh()
Expand Down Expand Up @@ -488,15 +494,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]
diivi marked this conversation as resolved.
Show resolved Hide resolved

for archive_name in archive_names:
if archive_name is not None:
params = BorgInfoArchiveJob.prepare(self.profile(), archive_name)
if params['ok']:
diivi marked this conversation as resolved.
Show resolved Hide resolved
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