mirror of
https://github.com/celogeek/go-qbittorrent-sync.git
synced 2025-05-24 16:02:37 +02:00
add rsh command
This commit is contained in:
parent
c3813c0192
commit
f38a80b9d3
2
main.go
2
main.go
@ -18,6 +18,7 @@ func main() {
|
|||||||
flag.StringVar(&rsyncoptions.Hostname, "rsync-hostname", "", "Rsync host")
|
flag.StringVar(&rsyncoptions.Hostname, "rsync-hostname", "", "Rsync host")
|
||||||
flag.StringVar(&rsyncoptions.Username, "rsync-username", "", "Rsync username")
|
flag.StringVar(&rsyncoptions.Username, "rsync-username", "", "Rsync username")
|
||||||
flag.StringVar(&rsyncoptions.Destination, "rsync-destination", ".", "Rsync Destination directory")
|
flag.StringVar(&rsyncoptions.Destination, "rsync-destination", ".", "Rsync Destination directory")
|
||||||
|
flag.StringVar(&rsyncoptions.Rsh, "rsync-rsh", ".", "Rsync rsh command")
|
||||||
flag.IntVar(&poolTime, "pool-time", 30, "Number of second to check new files to sync")
|
flag.IntVar(&poolTime, "pool-time", 30, "Number of second to check new files to sync")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ func main() {
|
|||||||
Username: rsyncoptions.Username,
|
Username: rsyncoptions.Username,
|
||||||
Hostname: rsyncoptions.Hostname,
|
Hostname: rsyncoptions.Hostname,
|
||||||
Destination: rsyncoptions.Destination,
|
Destination: rsyncoptions.Destination,
|
||||||
|
Rsh: rsyncoptions.Rsh,
|
||||||
Path: t.Path,
|
Path: t.Path,
|
||||||
OnProgress: func(p int) {
|
OnProgress: func(p int) {
|
||||||
err := qcli.SetProgress(t, p)
|
err := qcli.SetProgress(t, p)
|
||||||
|
16
rsync.go
16
rsync.go
@ -15,6 +15,7 @@ type RsyncOptions struct {
|
|||||||
Hostname string
|
Hostname string
|
||||||
Path string
|
Path string
|
||||||
Destination string
|
Destination string
|
||||||
|
Rsh string
|
||||||
OnProgress func(p int)
|
OnProgress func(p int)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ func (r *RsyncOptions) Uri() string {
|
|||||||
type Rsync struct {
|
type Rsync struct {
|
||||||
Source string
|
Source string
|
||||||
Destination string
|
Destination string
|
||||||
|
Rsh string
|
||||||
OnProgress func(p int)
|
OnProgress func(p int)
|
||||||
|
|
||||||
progress int
|
progress int
|
||||||
@ -38,6 +40,7 @@ func NewRsync(options *RsyncOptions) *Rsync {
|
|||||||
return &Rsync{
|
return &Rsync{
|
||||||
Source: options.Uri(),
|
Source: options.Uri(),
|
||||||
Destination: options.Destination,
|
Destination: options.Destination,
|
||||||
|
Rsh: options.Rsh,
|
||||||
OnProgress: options.OnProgress,
|
OnProgress: options.OnProgress,
|
||||||
progress: -1,
|
progress: -1,
|
||||||
}
|
}
|
||||||
@ -60,15 +63,20 @@ func ScanCR(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rsync) Run() error {
|
func (r *Rsync) Run() error {
|
||||||
cmd := exec.Command(
|
args := []string{
|
||||||
"rsync",
|
|
||||||
"--archive",
|
"--archive",
|
||||||
"--partial",
|
"--partial",
|
||||||
"--inplace",
|
"--inplace",
|
||||||
"--no-inc-recursive",
|
"--no-inc-recursive",
|
||||||
"--info=progress2",
|
"--info=progress2",
|
||||||
r.Source,
|
}
|
||||||
r.Destination,
|
if r.Rsh != "" {
|
||||||
|
args = append(args, "--rsh", r.Rsh)
|
||||||
|
}
|
||||||
|
args = append(args, r.Source, r.Destination)
|
||||||
|
cmd := exec.Command(
|
||||||
|
"rsync",
|
||||||
|
args...,
|
||||||
)
|
)
|
||||||
out, err := cmd.StdoutPipe()
|
out, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user