Merge pull request #4514 from grembo/key-list-no-lock

Make `key list` command honor `--no-lock`
This commit is contained in:
Michael Eischer 2023-10-19 20:50:56 +00:00 committed by GitHub
commit 17f2301cc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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,11 +212,14 @@ func runKey(ctx context.Context, gopts GlobalOptions, args []string) error {
switch args[0] { switch args[0] {
case "list": case "list":
lock, ctx, err := lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON) if !gopts.NoLock {
var lock *restic.Lock
lock, ctx, err = lockRepo(ctx, repo, gopts.RetryLock, gopts.JSON)
defer unlockRepo(lock) defer unlockRepo(lock)
if err != nil { if err != nil {
return err return err
} }
}
return listKeys(ctx, repo, gopts) return listKeys(ctx, repo, gopts)
case "add": case "add":