worker rsync 方式增加 --include-from 选项 \n worker配置文件增加 include_file 参数即可

This commit is contained in:
bubble 2018-08-15 13:41:21 +08:00
parent ef78563b8c
commit fc935d7b7d
3 changed files with 9 additions and 3 deletions

View File

@ -124,6 +124,7 @@ type mirrorConfig struct {
Command string `toml:"command"`
UseIPv6 bool `toml:"use_ipv6"`
UseIPv4 bool `toml:"use_ipv4"`
IncludeFile string `toml:"include_file"`
ExcludeFile string `toml:"exclude_file"`
Username string `toml:"username"`
Password string `toml:"password"`

View File

@ -126,6 +126,7 @@ func newMirrorProvider(mirror mirrorConfig, cfg *Config) mirrorProvider {
username: mirror.Username,
password: mirror.Password,
excludeFile: mirror.ExcludeFile,
includeFile: mirror.IncludeFile,
workingDir: mirrorDir,
logDir: logDir,
logFile: filepath.Join(logDir, "latest.log"),

View File

@ -9,7 +9,7 @@ import (
type rsyncConfig struct {
name string
rsyncCmd string
upstreamURL, username, password, excludeFile string
upstreamURL, username, password, excludeFile,includeFile string
workingDir, logDir, logFile string
useIPv6, useIPv4 bool
interval time.Duration
@ -41,8 +41,8 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
}
options := []string{
"-aHvh", "--no-o", "--no-g", "--stats",
"--exclude", ".~tmp~/",
"-aHvh", "--no-o", "--no-g", "--stats", "-n",
"--exclude", ".~tmp~/","--include",
"--delete", "--delete-after", "--delay-updates",
"--safe-links", "--timeout=120", "--contimeout=120",
}
@ -53,6 +53,10 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
options = append(options, "-4")
}
if c.includeFile !="" {
options = append(options, "--include-from", c.includeFile)
}
if c.excludeFile != "" {
options = append(options, "--exclude-from", c.excludeFile)
}