From 933b290e2ad23bbb59fc139bc25e4b51f6bcaeea Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Sun, 31 Dec 2023 11:20:21 +0100 Subject: [PATCH] Add list function permissions, rename earlier list to snapshot --- npbackup/core/runner.py | 28 +++++++++++++++++++--------- npbackup/gui/__main__.py | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/npbackup/core/runner.py b/npbackup/core/runner.py index 6eaf80b..a1107ab 100644 --- a/npbackup/core/runner.py +++ b/npbackup/core/runner.py @@ -318,11 +318,12 @@ class NPBackupRunner: required_permissions = { "backup": ["backup", "restore", "full"], "has_recent_snapshot": ["backup", "restore", "full"], - "list": ["backup", "restore", "full"], + "snapshots": ["backup", "restore", "full"], "ls": ["backup", "restore", "full"], "find": ["backup", "restore", "full"], "restore": ["restore", "full"], "check": ["restore", "full"], + "list": ["full"], "unlock": ["full"], "repair": ["full"], "forget": ["full"], @@ -633,13 +634,27 @@ class NPBackupRunner: @is_ready @apply_config_to_restic_runner @catch_exceptions - def list(self) -> Optional[dict]: + def snapshots(self) -> Optional[dict]: self.write_logs( f"Listing snapshots of repo {self.repo_config.g('name')}", level="info" ) - # TODO: replace with list("snapshots") snapshots = self.restic_runner.snapshots() return snapshots + + @threaded + @close_queues + @exec_timer + @check_concurrency + @has_permission + @is_ready + @apply_config_to_restic_runner + @catch_exceptions + def list(self, subject: str) -> Optional[dict]: + self.write_logs( + f"Listing {subject} objects of repo {self.repo_config.g('name')}", level="info" + ) + snapshots = self.restic_runner.list(subject) + return snapshots @threaded @close_queues @@ -1068,7 +1083,7 @@ class NPBackupRunner: @exec_timer @has_permission @catch_exceptions - def group_runner(self, repo_config_list: list, operation: str, **kwargs) -> bool: + def group_runner(self, repo_config_list: List, operation: str, **kwargs) -> bool: group_result = True # Make sure we don't close the stdout/stderr queues when running multiple operations @@ -1095,9 +1110,4 @@ class NPBackupRunner: ) group_result = False self.write_logs("Finished execution group operations", level="info") - # Manually close the queues at the end - # if self.stdout: - # self.stdout.put(None) - # if self.stderr: - # self.stderr.put(None) return group_result diff --git a/npbackup/gui/__main__.py b/npbackup/gui/__main__.py index 13280e1..2332ff8 100644 --- a/npbackup/gui/__main__.py +++ b/npbackup/gui/__main__.py @@ -495,7 +495,7 @@ def _main_gui(viewer_mode: bool): ) gui_msg = _t("main_gui.loading_snapshot_list_from_repo") snapshots = gui_thread_runner( - repo_config, "list", __gui_msg=gui_msg, __autoclose=True, __compact=True + repo_config, "snapshots", __gui_msg=gui_msg, __autoclose=True, __compact=True ) current_state, backup_tz = ResticRunner._has_recent_snapshot( snapshots, repo_config.g("repo_opts.minimum_backup_age")