"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sync: add filter-sensitivity to --backup-dir option
Nick Naumann11be920e90ec
diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex fc275c894..a02aead24 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -815,17 +815,6 @@ func fixRoot(f fs.Info) string {return s}-// Overlapping returns true if fdst and fsrc point to the same-// underlying Fs and they overlap.-func Overlapping(fdst, fsrc fs.Info) bool {- if !SameConfig(fdst, fsrc) {- return false- }- fdstRoot := fixRoot(fdst)- fsrcRoot := fixRoot(fsrc)- return strings.HasPrefix(fdstRoot, fsrcRoot) || strings.HasPrefix(fsrcRoot, fdstRoot)-}-// OverlappingFilterCheck returns true if fdst and fsrc point to the same// underlying Fs and they overlap without fdst being excluded by any filter rule.func OverlappingFilterCheck(ctx context.Context, fdst fs.Fs, fsrc fs.Fs) bool {@@ -1849,10 +1838,10 @@ func BackupDir(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, srcFileName string)return nil, fserrors.FatalError(errors.New("parameter to --backup-dir has to be on the same remote as destination"))}if srcFileName == "" {- if Overlapping(fdst, backupDir) {+ if OverlappingFilterCheck(ctx, backupDir, fdst) {return nil, fserrors.FatalError(errors.New("destination and parameter to --backup-dir mustn't overlap"))}- if Overlapping(fsrc, backupDir) {+ if OverlappingFilterCheck(ctx, backupDir, fsrc) {return nil, fserrors.FatalError(errors.New("source and parameter to --backup-dir mustn't overlap"))}} else {diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.goindex 34b88d6d1..20fcc61a0 100644--- a/fs/operations/operations_test.go+++ b/fs/operations/operations_test.go@@ -1243,35 +1243,6 @@ func TestSame(t *testing.T) {}}-func TestOverlapping(t *testing.T) {- a := &testFsInfo{name: "name", root: "root"}- slash := string(os.PathSeparator) // native path separator- for _, test := range []struct {- name string- root string- expected bool- }{- {"name", "root", true},- {"namey", "root", false},- {"name", "rooty", false},- {"namey", "rooty", false},- {"name", "roo", false},- {"name", "root/toot", true},- {"name", "root/toot/", true},- {"name", "root" + slash + "toot", true},- {"name", "root" + slash + "toot" + slash, true},- {"name", "", true},- {"name", "/", true},- } {- b := &testFsInfo{name: test.name, root: test.root}- what := fmt.Sprintf("(%q,%q) vs (%q,%q)", a.name, a.root, b.name, b.root)- actual := operations.Overlapping(a, b)- assert.Equal(t, test.expected, actual, what)- actual = operations.Overlapping(b, a)- assert.Equal(t, test.expected, actual, what)- }-}-// testFs is for unit testing fs.Fstype testFs struct {testFsInfo