Add list function permissions, rename earlier list to snapshot

This commit is contained in:
Orsiris de Jong 2023-12-31 11:20:21 +01:00
parent c8d10e6a76
commit 933b290e2a
2 changed files with 20 additions and 10 deletions

View file

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

View file

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