mirror of
https://github.com/restic/restic.git
synced 2026-02-03 04:20:45 -05:00
backend/util: extract background handling code
This commit is contained in:
parent
cc1fe6c111
commit
6ff7cd9050
6 changed files with 10 additions and 9 deletions
|
|
@ -21,9 +21,9 @@ import (
|
|||
"github.com/restic/restic/internal/backend/limiter"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
"github.com/restic/restic/internal/backend/rest"
|
||||
"github.com/restic/restic/internal/backend/util"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/terminal"
|
||||
"golang.org/x/net/http2"
|
||||
)
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ func run(command string, args ...string) (*StdioConn, *sync.WaitGroup, chan stru
|
|||
cmd.Stdin = r
|
||||
cmd.Stdout = w
|
||||
|
||||
bg, err := util.StartForeground(cmd)
|
||||
bg, err := terminal.StartForeground(cmd)
|
||||
// close rclone side of pipes
|
||||
errR := r.Close()
|
||||
errW := w.Close()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/feature"
|
||||
"github.com/restic/restic/internal/terminal"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"github.com/pkg/sftp"
|
||||
|
|
@ -84,7 +85,7 @@ func startClient(cfg Config) (*SFTP, error) {
|
|||
return nil, errors.Wrap(err, "cmd.StdoutPipe")
|
||||
}
|
||||
|
||||
bg, err := util.StartForeground(cmd)
|
||||
bg, err := terminal.StartForeground(cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, exec.ErrDot) {
|
||||
return nil, errors.Errorf("cannot implicitly run relative executable %v found in current directory, use -o sftp.command=./<command> to override", cmd.Path)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package util
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package util_test
|
||||
package terminal_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/backend/util"
|
||||
"github.com/restic/restic/internal/terminal"
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ func TestForeground(t *testing.T) {
|
|||
stdout, err := cmd.StdoutPipe()
|
||||
rtest.OK(t, err)
|
||||
|
||||
bg, err := util.StartForeground(cmd)
|
||||
bg, err := terminal.StartForeground(cmd)
|
||||
rtest.OK(t, err)
|
||||
defer func() {
|
||||
rtest.OK(t, cmd.Wait())
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//go:build unix
|
||||
|
||||
package util
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package util
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
Loading…
Reference in a new issue