From fc935d7b7d068a733289ada15b113f51d50faa61 Mon Sep 17 00:00:00 2001 From: bubble Date: Wed, 15 Aug 2018 13:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=20worker=20rsync=20=E6=96=B9=E5=BC=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20--include-from=20=E9=80=89=E9=A1=B9=20\n=20worker?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0=20includ?= =?UTF-8?q?e=5Ffile=20=E5=8F=82=E6=95=B0=E5=8D=B3=E5=8F=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/config.go | 1 + worker/provider.go | 1 + worker/rsync_provider.go | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) 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) }