mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
backend/rclone: Prefix all error messages
This commit is contained in:
parent
20352886f3
commit
6d9a029e09
@ -1,8 +1,10 @@
|
||||
package rclone
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -30,7 +32,18 @@ type Backend struct {
|
||||
// run starts command with args and initializes the StdioConn.
|
||||
func run(command string, args ...string) (*StdioConn, *exec.Cmd, func() error, error) {
|
||||
cmd := exec.Command(command, args...)
|
||||
cmd.Stderr = os.Stderr
|
||||
p, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
// start goroutine to add a prefix to all messages printed by to stderr by rclone
|
||||
go func() {
|
||||
sc := bufio.NewScanner(p)
|
||||
for sc.Scan() {
|
||||
fmt.Fprintf(os.Stderr, "rclone: %v\n", sc.Text())
|
||||
}
|
||||
}()
|
||||
|
||||
r, stdin, err := os.Pipe()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user