diff --git a/internal/backend/rclone/backend.go b/internal/backend/rclone/backend.go index fe371f6a0..c87a2f1b0 100644 --- a/internal/backend/rclone/backend.go +++ b/internal/backend/rclone/backend.go @@ -173,7 +173,8 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) { DialTLS: func(network, address string, cfg *tls.Config) (net.Conn, error) { debug.Log("new connection requested, %v %v", network, address) if dialCount > 0 { - panic("dial count > 0") + // the connection to the child process is already closed + return nil, errors.New("rclone stdio connection already closed") } dialCount++ return conn, nil diff --git a/internal/backend/rclone/internal_test.go b/internal/backend/rclone/internal_test.go index 435428870..da958f281 100644 --- a/internal/backend/rclone/internal_test.go +++ b/internal/backend/rclone/internal_test.go @@ -29,9 +29,11 @@ func TestRcloneExit(t *testing.T) { rtest.OK(t, err) t.Log("killed rclone") - _, err = be.Stat(context.TODO(), restic.Handle{ - Name: "foo", - Type: restic.DataFile, - }) - rtest.Assert(t, err != nil, "expected an error") + for i := 0; i < 10; i++ { + _, err = be.Stat(context.TODO(), restic.Handle{ + Name: "foo", + Type: restic.DataFile, + }) + rtest.Assert(t, err != nil, "expected an error") + } }