From 34f3b13b7c8e94d9785ad95c26726d158a83c0cf Mon Sep 17 00:00:00 2001 From: Michael Gmelin Date: Fri, 13 Oct 2023 12:49:17 +0200 Subject: [PATCH] Make `key list` command honor `--no-lock` Fixes #4513 --- changelog/unreleased/issue-4513 | 8 ++++++++ cmd/restic/cmd_key.go | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/issue-4513 diff --git a/changelog/unreleased/issue-4513 b/changelog/unreleased/issue-4513 new file mode 100644 index 000000000..aa79f2848 --- /dev/null +++ b/changelog/unreleased/issue-4513 @@ -0,0 +1,8 @@ +Bugfix: Make `key list` command honor `--no-lock` + +This allows to determine which keys a repo can be accessed by without the +need for having write access (e.g., read-only sftp access, filesystem +snapshot). + +https://github.com/restic/restic/issues/4513 +https://github.com/restic/restic/pull/4514 diff --git a/cmd/restic/cmd_key.go b/cmd/restic/cmd_key.go index 62521d762..ab41b4be3 100644 --- a/cmd/restic/cmd_key.go +++ b/cmd/restic/cmd_key.go @@ -212,10 +212,13 @@ func runKey(ctx context.Context, gopts GlobalOptions, args []string) error { switch args[0] { case "list": - lock, ctx, err := lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON) - defer unlockRepo(lock) - if err != nil { - return err + if !gopts.NoLock { + var lock *restic.Lock + lock, ctx, err = lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON) + defer unlockRepo(lock) + if err != nil { + return err + } } return listKeys(ctx, repo, gopts)