From f3d964a8c179125de0c7ea2593157ab516179347 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 2 Dec 2022 20:46:02 +0100 Subject: [PATCH] rclone: treat "file already closed" as command startup error Since #3940 the rclone backend returns the commands exit code if it fails to start. The list of expected errors was missing the "file already closed"-error which can occur if the http test request first learns about the closed pipe to rclone before noticing the canceled context. Go internally makes sure that a file descriptor is unusable once it was closed, thus this cannot have unintended side effects (like accidentally reading from the wrong file due to a reused file descriptor). --- internal/backend/rclone/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/backend/rclone/backend.go b/internal/backend/rclone/backend.go index 97ed417a3..085c89945 100644 --- a/internal/backend/rclone/backend.go +++ b/internal/backend/rclone/backend.go @@ -239,7 +239,7 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) { // wait for rclone to exit wg.Wait() // try to return the program exit code if communication with rclone has failed - if be.waitResult != nil && (errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE)) { + if be.waitResult != nil && (errors.Is(err, context.Canceled) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE) || errors.Is(err, os.ErrClosed)) { err = be.waitResult }