diff --git a/worker/config.go b/worker/config.go index f178ec5..9e585e2 100644 --- a/worker/config.go +++ b/worker/config.go @@ -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"` diff --git a/worker/provider.go b/worker/provider.go index fe787b4..ae7b549 100644 --- a/worker/provider.go +++ b/worker/provider.go @@ -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"), diff --git a/worker/rsync_provider.go b/worker/rsync_provider.go index b9d8fd5..44abdb2 100644 --- a/worker/rsync_provider.go +++ b/worker/rsync_provider.go @@ -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) }