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 {