"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
filter: Fix incorrect filtering with UseFilter context flag and wrapping backends
Nick Craig-Woodbd787e8f4577
diff --git a/backend/drive/drive.go b/backend/drive/drive.goindex 30c165b61..e0b4abb61 100644--- a/backend/drive/drive.go+++ b/backend/drive/drive.go@@ -1210,6 +1210,7 @@ func newFs(ctx context.Context, name, path string, m configmap.Mapper) (*Fs, errWriteMimeType: true,CanHaveEmptyDirectories: true,ServerSideAcrossConfigs: opt.ServerSideAcrossConfigs,+ FilterAware: true,}).Fill(ctx, f)// Create a new authorized Drive client.diff --git a/backend/drive/drive_internal_test.go b/backend/drive/drive_internal_test.goindex 22a84b0bb..c17da7062 100644--- a/backend/drive/drive_internal_test.go+++ b/backend/drive/drive_internal_test.go@@ -518,6 +518,9 @@ func (f *Fs) InternalTestCopyID(t *testing.T) {// TestIntegration/FsMkdir/FsPutFiles/Internal/AgeQueryfunc (f *Fs) InternalTestAgeQuery(t *testing.T) {+ // Check set up for filtering+ assert.True(t, f.Features().FilterAware)+opt := &filter.Opt{}err := opt.MaxAge.Set("1h")assert.NoError(t, err)diff --git a/backend/local/local.go b/backend/local/local.goindex 18763ace3..7d56d8012 100644--- a/backend/local/local.go+++ b/backend/local/local.go@@ -300,6 +300,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, eReadMetadata: true,WriteMetadata: true,UserMetadata: xattrSupported, // can only R/W general purpose metadata if xattrs are supported+ FilterAware: true,}).Fill(ctx, f)if opt.FollowSymlinks {f.lstat = os.Statdiff --git a/backend/local/local_internal_test.go b/backend/local/local_internal_test.goindex 811831d91..7ecc9986b 100644--- a/backend/local/local_internal_test.go+++ b/backend/local/local_internal_test.go@@ -378,6 +378,9 @@ func TestFilter(t *testing.T) {r.WriteFile("excluded", "excluded file", when)f := r.Flocal.(*Fs)+ // Check set up for filtering+ assert.True(t, f.Features().FilterAware)+// Add a filterctx, fi := filter.AddConfig(ctx)require.NoError(t, fi.AddRule("+ included"))diff --git a/fs/features.go b/fs/features.goindex 6fce02d60..b8bbffc21 100644--- a/fs/features.go+++ b/fs/features.go@@ -29,6 +29,7 @@ type Features struct {ReadMetadata bool // can read metadata from objectsWriteMetadata bool // can write metadata to objectsUserMetadata bool // can read/write general purpose metadata+ FilterAware bool // can make use of filters if provided for listing// Purge all files in the directory specified//@@ -320,6 +321,7 @@ func (ft *Features) Mask(ctx context.Context, f Fs) *Features {// ft.IsLocal = ft.IsLocal && mask.IsLocal Don't propagate IsLocalft.SlowModTime = ft.SlowModTime && mask.SlowModTimeft.SlowHash = ft.SlowHash && mask.SlowHash+ ft.FilterAware = ft.FilterAware && mask.FilterAwareif mask.Purge == nil {ft.Purge = nildiff --git a/fs/march/march.go b/fs/march/march.goindex db045156d..771f079f4 100644--- a/fs/march/march.go+++ b/fs/march/march.go@@ -83,7 +83,7 @@ func (m *March) makeListDir(ctx context.Context, f fs.Fs, includeAll bool) listDif !(ci.UseListR && f.Features().ListR != nil) && // !--fast-list active and!(ci.NoTraverse && fi.HaveFilesFrom()) { // !(--files-from and --no-traverse)return func(dir string) (entries fs.DirEntries, err error) {- dirCtx := filter.SetUseFilter(m.Ctx, !includeAll) // make filter-aware backends constrain List+ dirCtx := filter.SetUseFilter(m.Ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain Listreturn list.DirSorted(dirCtx, f, includeAll, dir)}}@@ -100,7 +100,7 @@ func (m *March) makeListDir(ctx context.Context, f fs.Fs, includeAll bool) listDmu.Lock()defer mu.Unlock()if !started {- dirCtx := filter.SetUseFilter(m.Ctx, !includeAll) // make filter-aware backends constrain List+ dirCtx := filter.SetUseFilter(m.Ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain Listdirs, dirsErr = walk.NewDirTree(dirCtx, f, m.Dir, includeAll, ci.MaxDepth)started = true}diff --git a/fs/walk/walk.go b/fs/walk/walk.goindex f63350a47..01251ea1b 100644--- a/fs/walk/walk.go+++ b/fs/walk/walk.go@@ -64,7 +64,7 @@ type Func func(path string, entries fs.DirEntries, err error) errorfunc Walk(ctx context.Context, f fs.Fs, path string, includeAll bool, maxLevel int, fn Func) error {ci := fs.GetConfig(ctx)fi := filter.GetConfig(ctx)- ctx = filter.SetUseFilter(ctx, !includeAll) // make filter-aware backends constrain List+ ctx = filter.SetUseFilter(ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain Listif ci.NoTraverse && fi.HaveFilesFrom() {return walkR(ctx, f, path, includeAll, maxLevel, fn, fi.MakeListR(ctx, f.NewObject))}@@ -158,7 +158,7 @@ func ListR(ctx context.Context, f fs.Fs, path string, includeAll bool, maxLevelfi.UsesDirectoryFilters() { // ...using any directory filtersreturn listRwalk(ctx, f, path, includeAll, maxLevel, listType, fn)}- ctx = filter.SetUseFilter(ctx, !includeAll) // make filter-aware backends constrain List+ ctx = filter.SetUseFilter(ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain Listreturn listR(ctx, f, path, includeAll, listType, fn, doListR, listType.Dirs() && f.Features().BucketBased)}