Make `key list` command honor `--no-lock`

Fixes #4513
This commit is contained in:
Michael Gmelin 2023-10-13 12:49:17 +02:00 committed by Michael Eischer
parent 495982232c
commit 34f3b13b7c
2 changed files with 15 additions and 4 deletions

View File

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

View File

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