From b64537f70da2d76cf322c059820ca1c6ce46667e Mon Sep 17 00:00:00 2001 From: Ivan Andreev Date: Sat, 20 Nov 2021 22:59:30 +0300 Subject: [PATCH] drive: prevent retries when query filter returned no entries https://forum.rclone.org/t/performance-degradation-between-v1-56-2-and-v1-57-0-when-copying-to-google-drive-using-max-age-min-age-and-fast-list/27580/2 --- backend/drive/drive.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 01e3fd6a4..2aacb71a1 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -1693,6 +1693,11 @@ func (f *Fs) listRRunner(ctx context.Context, wg *sync.WaitGroup, in chan listRE var paths []string var grouping int32 + usingQueryFilter := false + if fi, use := filter.GetConfig(ctx), filter.GetUseFilter(ctx); fi != nil && use { + usingQueryFilter = true + } + for dir := range in { dirs = append(dirs[:0], dir.id) paths = append(paths[:0], dir.path) @@ -1765,7 +1770,8 @@ func (f *Fs) listRRunner(ctx context.Context, wg *sync.WaitGroup, in chan listRE // drive where (A in parents) or (B in parents) returns nothing // sometimes. See #3114, #4289 and // https://issuetracker.google.com/issues/149522397 - if len(dirs) > 1 && !foundItems { + // However, empty result is legitimate if query filter was applied. + if len(dirs) > 1 && !foundItems && !usingQueryFilter { if atomic.SwapInt32(&f.grouping, 1) != 1 { fs.Debugf(f, "Disabling ListR to work around bug in drive as multi listing (%d) returned no entries", len(dirs)) } @@ -1783,7 +1789,8 @@ func (f *Fs) listRRunner(ctx context.Context, wg *sync.WaitGroup, in chan listRE } // If using a grouping of 1 and dir was empty then check to see if it // is part of the group that caused grouping to be disabled. - if grouping == 1 && len(dirs) == 1 && !foundItems { + // However, empty result is legitimate if query filter was applied. + if grouping == 1 && len(dirs) == 1 && !foundItems && !usingQueryFilter { f.listRmu.Lock() if _, found := f.listRempties[dirs[0]]; found { // Remove the ID