镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 06:26:46 +00:00
feature(worker): implemented rsync provider
这个提交包含在:
@@ -4,6 +4,7 @@ import "time"
|
||||
|
||||
type rsyncConfig struct {
|
||||
name string
|
||||
rsyncCmd string
|
||||
upstreamURL, password, excludeFile string
|
||||
workingDir, logDir, logFile string
|
||||
useIPv6 bool
|
||||
@@ -14,6 +15,7 @@ type rsyncConfig struct {
|
||||
type rsyncProvider struct {
|
||||
baseProvider
|
||||
rsyncConfig
|
||||
options []string
|
||||
}
|
||||
|
||||
func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
|
||||
@@ -27,6 +29,25 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
|
||||
rsyncConfig: c,
|
||||
}
|
||||
|
||||
if c.rsyncCmd == "" {
|
||||
provider.rsyncCmd = "rsync"
|
||||
}
|
||||
|
||||
options := []string{
|
||||
"-aHvh", "--no-o", "--no-g", "--stats",
|
||||
"--exclude", ".~tmp~/",
|
||||
"--delete", "--delete-after", "--delay-updates",
|
||||
"--safe-links", "--timeout=120", "--contimeout=120",
|
||||
}
|
||||
|
||||
if c.useIPv6 {
|
||||
options = append(options, "-6")
|
||||
}
|
||||
|
||||
if c.excludeFile != "" {
|
||||
options = append(options, "--exclude-from", c.excludeFile)
|
||||
}
|
||||
|
||||
provider.ctx.Set(_WorkingDirKey, c.workingDir)
|
||||
provider.ctx.Set(_LogDirKey, c.logDir)
|
||||
provider.ctx.Set(_LogFileKey, c.logFile)
|
||||
@@ -34,17 +55,19 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
|
||||
return provider, nil
|
||||
}
|
||||
|
||||
// TODO: implement this
|
||||
func (p *rsyncProvider) Start() error {
|
||||
return nil
|
||||
}
|
||||
env := map[string]string{}
|
||||
if p.password != "" {
|
||||
env["RSYNC_PASSWORD"] = p.password
|
||||
}
|
||||
command := []string{p.rsyncCmd}
|
||||
command = append(command, p.options...)
|
||||
command = append(command, p.upstreamURL, p.WorkingDir())
|
||||
|
||||
// TODO: implement this
|
||||
func (p *rsyncProvider) Terminate() error {
|
||||
return nil
|
||||
}
|
||||
p.cmd = newCmdJob(command, p.WorkingDir(), env)
|
||||
if err := p.setLogFile(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: implement this
|
||||
func (p *rsyncProvider) Wait() error {
|
||||
return nil
|
||||
return p.cmd.Start()
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户