From d18726cd70527ff5d77f0d418585659834684756 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 24 Feb 2024 21:52:28 +0100 Subject: [PATCH] ls: add missing read lock As `ls` reads data from the repository, it must acquire a read lock unless `--no-lock` was specified. The old behavior is equivalent to `ls --no-lock`. --- cmd/restic/cmd_ls.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index b0246625e..c4fb32de3 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -309,10 +309,11 @@ func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []stri return false } - repo, err := OpenRepository(ctx, gopts) + ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock) if err != nil { return err } + defer unlock() snapshotLister, err := restic.MemorizeList(ctx, repo, restic.SnapshotFile) if err != nil {