From a251267970738b61d7f3ba687496c5da9be32145 Mon Sep 17 00:00:00 2001 From: idawnlight Date: Wed, 20 Sep 2023 15:49:36 +0800 Subject: [PATCH] feat: add IncludeFile for rsync provider --- worker/config.go | 1 + worker/rsync_provider.go | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/worker/config.go b/worker/config.go index bfc0790..276e402 100644 --- a/worker/config.go +++ b/worker/config.go @@ -173,6 +173,7 @@ type mirrorConfig struct { UseIPv6 bool `toml:"use_ipv6"` UseIPv4 bool `toml:"use_ipv4"` ExcludeFile string `toml:"exclude_file"` + IncludeFile string `toml:"include_file"` Username string `toml:"username"` Password string `toml:"password"` RsyncNoTimeo bool `toml:"rsync_no_timeout"` diff --git a/worker/rsync_provider.go b/worker/rsync_provider.go index 6283055..c4429b2 100644 --- a/worker/rsync_provider.go +++ b/worker/rsync_provider.go @@ -10,19 +10,20 @@ import ( ) type rsyncConfig struct { - name string - rsyncCmd string - upstreamURL, username, password, excludeFile string - extraOptions []string - overriddenOptions []string - rsyncNeverTimeout bool - rsyncTimeoutValue int - rsyncEnv map[string]string - workingDir, logDir, logFile string - useIPv6, useIPv4 bool - interval time.Duration - retry int - timeout time.Duration + name string + rsyncCmd string + upstreamURL, username, password string + excludeFile, includeFile string + extraOptions []string + overriddenOptions []string + rsyncNeverTimeout bool + rsyncTimeoutValue int + rsyncEnv map[string]string + workingDir, logDir, logFile string + useIPv6, useIPv4 bool + interval time.Duration + retry int + timeout time.Duration uid int gid int @@ -95,6 +96,9 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) { if c.excludeFile != "" { options = append(options, "--exclude-from", c.excludeFile) } + if c.includeFile != "" { + options = append(options, "--include-from", c.includeFile) + } if c.extraOptions != nil { options = append(options, c.extraOptions...) }