mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
Fix --files-from without --no-traverse doing a recursive scan
In a28239f005
we made --files-from obey --no-traverse. In the
process this caused --files-from without --no-traverse to do a
complete recursive scan unecessarily.
This was only noticeable in users of fs/march, so sync/copy/move/etc
not in ls/lsf/etc.
This fix makes sure that we use conventional directory listings in
fs/march unless `--files-from` and `--no-traverse` is set or
`--fast-list` is active.
Fixes #3619
This commit is contained in:
parent
f9f9d5029b
commit
af05e290cf
@ -69,13 +69,18 @@ func (m *March) init() {
|
||||
// list a directory into entries, err
|
||||
type listDirFn func(dir string) (entries fs.DirEntries, err error)
|
||||
|
||||
// makeListDir makes a listing function for the given fs and includeAll flags
|
||||
// makeListDir makes constructs a listing function for the given fs
|
||||
// and includeAll flags for marching through the file system.
|
||||
func (m *March) makeListDir(f fs.Fs, includeAll bool) listDirFn {
|
||||
if (!fs.Config.UseListR || f.Features().ListR == nil) && !filter.Active.HaveFilesFrom() {
|
||||
if !(fs.Config.UseListR && f.Features().ListR != nil) && // !--fast-list active and
|
||||
!(fs.Config.NoTraverse && filter.Active.HaveFilesFrom()) { // !(--files-from and --no-traverse)
|
||||
return func(dir string) (entries fs.DirEntries, err error) {
|
||||
return list.DirSorted(m.Ctx, f, includeAll, dir)
|
||||
}
|
||||
}
|
||||
|
||||
// This returns a closure for use when --fast-list is active or for when
|
||||
// --files-from and --no-traverse is set
|
||||
var (
|
||||
mu sync.Mutex
|
||||
started bool
|
||||
|
@ -553,12 +553,15 @@ func walkNDirTree(ctx context.Context, f fs.Fs, path string, includeAll bool, ma
|
||||
//
|
||||
// NB (f, path) to be replaced by fs.Dir at some point
|
||||
func NewDirTree(ctx context.Context, f fs.Fs, path string, includeAll bool, maxLevel int) (dirtree.DirTree, error) {
|
||||
// if --no-traverse and --files-from build DirTree just from files
|
||||
if fs.Config.NoTraverse && filter.Active.HaveFilesFrom() {
|
||||
return walkRDirTree(ctx, f, path, includeAll, maxLevel, filter.Active.MakeListR(ctx, f.NewObject))
|
||||
}
|
||||
if ListR := f.Features().ListR; (maxLevel < 0 || maxLevel > 1) && ListR != nil {
|
||||
// if have ListR; and recursing; and not using --files-from; then build a DirTree with ListR
|
||||
if ListR := f.Features().ListR; (maxLevel < 0 || maxLevel > 1) && ListR != nil && !filter.Active.HaveFilesFrom() {
|
||||
return walkRDirTree(ctx, f, path, includeAll, maxLevel, ListR)
|
||||
}
|
||||
// otherwise just use List
|
||||
return walkNDirTree(ctx, f, path, includeAll, maxLevel, list.DirSorted)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user