mirror of
https://github.com/restic/restic.git
synced 2025-08-13 19:56:42 +00:00
rclone: return rclone error instead of canceled context
When rclone fails during the connection setup this currently often results in a context canceled error. Replace this error with the exit code from rclone.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
@@ -244,7 +245,15 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) {
|
||||
// ignore subsequent errors
|
||||
_ = bg()
|
||||
_ = cmd.Process.Kill()
|
||||
return nil, errors.Errorf("error talking HTTP to rclone: %v", err)
|
||||
|
||||
// wait for rclone to exit
|
||||
wg.Wait()
|
||||
// try to return the program exit code if communication with rclone has failed
|
||||
if be.waitResult != nil && (err == context.Canceled || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.EPIPE)) {
|
||||
err = be.waitResult
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("error talking HTTP to rclone: %w", err)
|
||||
}
|
||||
|
||||
debug.Log("HTTP status %q returned, moving instance to background", res.Status)
|
||||
|
Reference in New Issue
Block a user