2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

rclone: Return one fewer value from run

This commit is contained in:
greatroar 2021-08-26 18:12:08 +02:00
parent fa3eed1998
commit 950b818274

View File

@ -36,12 +36,12 @@ type Backend struct {
} }
// run starts command with args and initializes the StdioConn. // 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...) cmd := exec.Command(command, args...)
p, err := cmd.StderrPipe() p, err := cmd.StderrPipe()
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, err
} }
var wg sync.WaitGroup var wg sync.WaitGroup
@ -58,7 +58,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup
r, stdin, err := os.Pipe() r, stdin, err := os.Pipe()
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, err
} }
stdout, w, err := os.Pipe() 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 // close first pipe and ignore subsequent errors
_ = r.Close() _ = r.Close()
_ = stdin.Close() _ = stdin.Close()
return nil, nil, nil, nil, err return nil, nil, nil, err
} }
cmd.Stdin = r cmd.Stdin = r
@ -84,7 +84,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup
err = errW err = errW
} }
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, err
} }
c := &StdioConn{ c := &StdioConn{
@ -93,7 +93,7 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup
cmd: cmd, cmd: cmd,
} }
return c, cmd, &wg, bg, nil return c, &wg, bg, nil
} }
// wrappedConn adds bandwidth limiting capabilities to the StdioConn by // 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:] arg0, args := args[0], args[1:]
debug.Log("running command: %v %v", arg0, args) 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 { if err != nil {
return nil, err return nil, err
} }
@ -181,6 +181,7 @@ func newBackend(cfg Config, lim limiter.Limiter) (*Backend, error) {
}, },
} }
cmd := stdioConn.cmd
waitCh := make(chan struct{}) waitCh := make(chan struct{})
be := &Backend{ be := &Backend{
tr: tr, tr: tr,