From 9be4fe3e8401ea782ed6f5f3ab7ba321f28ee5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Mon, 6 Jul 2020 02:26:21 +0200 Subject: [PATCH] cmd/mount: honour --no-lock flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not lock the repository if --no-lock global flag is set. This allows to mount repositories which are archived on a read only system. Signed-off-by: Sébastien Gross --- changelog/unreleased/pull-2821 | 8 ++++++++ cmd/restic/cmd_mount.go | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/pull-2821 diff --git a/changelog/unreleased/pull-2821 b/changelog/unreleased/pull-2821 new file mode 100644 index 000000000..ee0d7b483 --- /dev/null +++ b/changelog/unreleased/pull-2821 @@ -0,0 +1,8 @@ +Change: Honor the --no-lock flag in the mount command + +The mount command now does not lock the repository if given the +--no-lock flag. This allows to mount repositories which are archived +on a read only backend/filesystem. + +https://github.com/restic/restic/issues/1597 +https://github.com/restic/restic/pull/2821 diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index 59fb4e82a..626915dfe 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -90,10 +90,12 @@ func mount(opts MountOptions, gopts GlobalOptions, mountpoint string) error { return err } - lock, err := lockRepo(repo) - defer unlockRepo(lock) - if err != nil { - return err + if !gopts.NoLock { + lock, err := lockRepo(repo) + defer unlockRepo(lock) + if err != nil { + return err + } } err = repo.LoadIndex(gopts.ctx)