From 984f8a1eb55456160d3423e3bc072639010b12d4 Mon Sep 17 00:00:00 2001 From: Chen Date: Mon, 14 Sep 2020 14:48:20 +0800 Subject: [PATCH] Update two stage rsync profiles (#135) * Update two stage rsync profiles * Fix tests of two stage rsync provider --- worker/provider_test.go | 4 ++-- worker/two_stage_rsync_provider.go | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/worker/provider_test.go b/worker/provider_test.go index 4b0a4c0..8dc3f96 100644 --- a/worker/provider_test.go +++ b/worker/provider_test.go @@ -614,7 +614,7 @@ exit 0 targetDir, fmt.Sprintf( "-aHvh --no-o --no-g --stats --exclude .~tmp~/ --safe-links "+ - "--exclude dists/ --timeout=30 -6 "+ + "--include=*.diff/ --exclude=*.diff/Index --exclude=Packages* --exclude=Sources* --exclude=Release* --exclude=InRelease --include=i18n/by-hash --exclude=i18n/* --exclude=ls-lR* --timeout=30 -6 "+ "--exclude-from %s %s %s", provider.excludeFile, provider.upstreamURL, provider.WorkingDir(), ), @@ -656,7 +656,7 @@ exit 0 expectedOutput := fmt.Sprintf( "-aHvh --no-o --no-g --stats --exclude .~tmp~/ --safe-links "+ - "--exclude dists/ --timeout=30 -6 "+ + "--include=*.diff/ --exclude=*.diff/Index --exclude=Packages* --exclude=Sources* --exclude=Release* --exclude=InRelease --include=i18n/by-hash --exclude=i18n/* --exclude=ls-lR* --timeout=30 -6 "+ "--exclude-from %s %s %s\n", provider.excludeFile, provider.upstreamURL, provider.WorkingDir(), ) diff --git a/worker/two_stage_rsync_provider.go b/worker/two_stage_rsync_provider.go index f0ca6c4..657c463 100644 --- a/worker/two_stage_rsync_provider.go +++ b/worker/two_stage_rsync_provider.go @@ -34,11 +34,12 @@ type twoStageRsyncProvider struct { dataSize string } +// ref: https://salsa.debian.org/mirror-team/archvsync/-/blob/master/bin/ftpsync#L431 var rsyncStage1Profiles = map[string]([]string){ - "debian": []string{"dists/"}, + "debian": []string{"--include=*.diff/", "--exclude=*.diff/Index", "--exclude=Packages*", "--exclude=Sources*", "--exclude=Release*", "--exclude=InRelease", "--include=i18n/by-hash", "--exclude=i18n/*", "--exclude=ls-lR*"}, "debian-oldstyle": []string{ - "Packages*", "Sources*", "Release*", - "InRelease", "i18n/*", "ls-lR*", "dep11/*", + "--exclude=Packages*", "--exclude=Sources*", "--exclude=Release*", + "--exclude=InRelease", "--exclude=i18n/*", "--exclude=ls-lR*", "--exclude=dep11/*", }, } @@ -109,12 +110,12 @@ func (p *twoStageRsyncProvider) Options(stage int) ([]string, error) { var options []string if stage == 1 { options = append(options, p.stage1Options...) - stage1Excludes, ok := rsyncStage1Profiles[p.stage1Profile] + stage1Profile, ok := rsyncStage1Profiles[p.stage1Profile] if !ok { return nil, errors.New("Invalid Stage 1 Profile") } - for _, exc := range stage1Excludes { - options = append(options, "--exclude", exc) + for _, exc := range stage1Profile { + options = append(options, exc) } } else if stage == 2 {