镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 06:26:46 +00:00
add support of env config for rsync provider
这个提交包含在:
@@ -15,6 +15,7 @@ type rsyncConfig struct {
|
||||
upstreamURL, username, password, excludeFile string
|
||||
extraOptions []string
|
||||
overriddenOptions []string
|
||||
rsyncEnv map[string]string
|
||||
workingDir, logDir, logFile string
|
||||
useIPv6, useIPv4 bool
|
||||
interval time.Duration
|
||||
@@ -50,6 +51,12 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
|
||||
if c.rsyncCmd == "" {
|
||||
provider.rsyncCmd = "rsync"
|
||||
}
|
||||
if c.username != "" {
|
||||
c.rsyncEnv["USER"] = c.username
|
||||
}
|
||||
if c.password != "" {
|
||||
c.rsyncEnv["RSYNC_PASSWORD"] = c.password
|
||||
}
|
||||
|
||||
options := []string{
|
||||
"-aHvh", "--no-o", "--no-g", "--stats",
|
||||
@@ -116,18 +123,11 @@ func (p *rsyncProvider) Start() error {
|
||||
return errors.New("provider is currently running")
|
||||
}
|
||||
|
||||
env := map[string]string{}
|
||||
if p.username != "" {
|
||||
env["USER"] = p.username
|
||||
}
|
||||
if p.password != "" {
|
||||
env["RSYNC_PASSWORD"] = p.password
|
||||
}
|
||||
command := []string{p.rsyncCmd}
|
||||
command = append(command, p.options...)
|
||||
command = append(command, p.upstreamURL, p.WorkingDir())
|
||||
|
||||
p.cmd = newCmdJob(p, command, p.WorkingDir(), env)
|
||||
p.cmd = newCmdJob(p, command, p.WorkingDir(), p.rsyncEnv)
|
||||
if err := p.prepareLogFile(false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户