walk: fix listing with filters listing whole remote

Prior to this fix, a request such as

    rclone lsf -R --include "/dir/**" remote:

Would use ListR which is very inefficient as it lists the whole remote
for one directory.

This changes it to use recursive walking if the filters imply any
directory filtering.  So `--include *.jpg` and `--exclude *.jpg` will
still use ListR wheras `--include "/dir/**` will not.
This commit is contained in:
Nick Craig-Wood 2019-08-06 22:21:19 +01:00
parent a00a0471a8
commit 6c38bddf3e
1 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ type Func func(path string, entries fs.DirEntries, err error) error
//
// Parent directories are always listed before their children
//
// This is implemented by WalkR if Config.UseUseListR is true
// This is implemented by WalkR if Config.UseListR is true
// and f supports it and level > 1, or WalkN otherwise.
//
// If --files-from and --no-traverse is set then a DirTree will be
@ -146,7 +146,7 @@ func ListR(ctx context.Context, f fs.Fs, path string, includeAll bool, maxLevel
filter.Active.HaveFilesFrom() || // ...using --files-from
maxLevel >= 0 || // ...using bounded recursion
len(filter.Active.Opt.ExcludeFile) > 0 || // ...using --exclude-file
filter.Active.BoundedRecursion() { // ...filters imply bounded recursion
filter.Active.UsesDirectoryFilters() { // ...using any directory filters
return listRwalk(ctx, f, path, includeAll, maxLevel, listType, fn)
}
return listR(ctx, f, path, includeAll, listType, fn, doListR, listType.Dirs() && f.Features().BucketBased)