From 237d00000eb97b75c79c7130de21cebb3594ba58 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 2 Jun 2023 23:16:49 +0200 Subject: [PATCH] lock: fix missing hint to unlock command if repository is locked --- cmd/restic/lock.go | 3 ++- cmd/restic/lock_test.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/restic/lock.go b/cmd/restic/lock.go index f7bba9b2f..336b56ad1 100644 --- a/cmd/restic/lock.go +++ b/cmd/restic/lock.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "sync" "time" @@ -97,7 +98,7 @@ retryLoop: return nil, ctx, errors.Fatalf("%v\n\nthe `unlock --remove-all` command can be used to remove invalid locks. Make sure that no other restic process is accessing the repository when running the command", err) } if err != nil { - return nil, ctx, errors.Fatalf("unable to create lock in backend: %v", err) + return nil, ctx, fmt.Errorf("unable to create lock in backend: %w", err) } debug.Log("create lock %p (exclusive %v)", lock, exclusive) diff --git a/cmd/restic/lock_test.go b/cmd/restic/lock_test.go index a07231f6d..150bd8730 100644 --- a/cmd/restic/lock_test.go +++ b/cmd/restic/lock_test.go @@ -90,6 +90,7 @@ func TestLockConflict(t *testing.T) { if err == nil { t.Fatal("second lock should have failed") } + test.Assert(t, restic.IsAlreadyLocked(err), "unexpected error %v", err) } type writeOnceBackend struct {