From 950b81827499e04227f9cb7d88f628ef68b2b849 Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Thu, 26 Aug 2021 18:12:08 +0200 Subject: [PATCH] rclone: Return one fewer value from run --- internal/backend/rclone/backend.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/backend/rclone/backend.go b/internal/backend/rclone/backend.go index e1dbf656e..8e0c7fe4d 100644 --- a/internal/backend/rclone/backend.go +++ b/internal/backend/rclone/backend.go @@ -36,12 +36,12 @@ type Backend struct { } // run starts command with args and initializes the StdioConn. -func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup, func() error, error) { +func run(command string, args ...string) (*StdioConn, *sync.WaitGroup, func() error, error) { cmd := exec.Command(command, args...) p, err := cmd.StderrPipe() if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } var wg sync.WaitGroup @@ -58,7 +58,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup r, stdin, err := os.Pipe() if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } stdout, w, err := os.Pipe() @@ -66,7 +66,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup // close first pipe and ignore subsequent errors _ = r.Close() _ = stdin.Close() - return nil, nil, nil, nil, err + return nil, nil, nil, err } cmd.Stdin = r @@ -84,7 +84,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup err = errW } if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } c := &StdioConn{ @@ -93,7 +93,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup cmd: cmd, } - return c, cmd, &wg, bg, nil + return c, &wg, bg, nil } // wrappedConn adds bandwidth limiting capabilities to the StdioConn by @@ -157,7 +157,7 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) { arg0, args := args[0], args[1:] debug.Log("running command: %v %v", arg0, args) - stdioConn, cmd, wg, bg, err := run(arg0, args...) + stdioConn, wg, bg, err := run(arg0, args...) if err != nil { return nil, err } @@ -181,6 +181,7 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) { }, } + cmd := stdioConn.cmd waitCh := make(chan struct{}) be := &Backend{ tr: tr,