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.Username, "rsync-username", "", "Rsync username")
|
||||
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.Parse()
|
||||
|
||||
@ -59,6 +60,7 @@ func main() {
|
||||
Username: rsyncoptions.Username,
|
||||
Hostname: rsyncoptions.Hostname,
|
||||
Destination: rsyncoptions.Destination,
|
||||
Rsh: rsyncoptions.Rsh,
|
||||
Path: t.Path,
|
||||
OnProgress: func(p int) {
|
||||
err := qcli.SetProgress(t, p)
|
||||
|
16
rsync.go
16
rsync.go
@ -15,6 +15,7 @@ type RsyncOptions struct {
|
||||
Hostname string
|
||||
Path string
|
||||
Destination string
|
||||
Rsh string
|
||||
OnProgress func(p int)
|
||||
}
|
||||
|
||||
@ -29,6 +30,7 @@ func (r *RsyncOptions) Uri() string {
|
||||
type Rsync struct {
|
||||
Source string
|
||||
Destination string
|
||||
Rsh string
|
||||
OnProgress func(p int)
|
||||
|
||||
progress int
|
||||
@ -38,6 +40,7 @@ func NewRsync(options *RsyncOptions) *Rsync {
|
||||
return &Rsync{
|
||||
Source: options.Uri(),
|
||||
Destination: options.Destination,
|
||||
Rsh: options.Rsh,
|
||||
OnProgress: options.OnProgress,
|
||||
progress: -1,
|
||||
}
|
||||
@ -60,15 +63,20 @@ func ScanCR(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
||||
}
|
||||
|
||||
func (r *Rsync) Run() error {
|
||||
cmd := exec.Command(
|
||||
"rsync",
|
||||
args := []string{
|
||||
"--archive",
|
||||
"--partial",
|
||||
"--inplace",
|
||||
"--no-inc-recursive",
|
||||
"--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()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user