diff --git a/backend/drive/drive.go b/backend/drive/drive.go index b85ce4a3c..c33a615ed 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -598,6 +598,28 @@ resource key is not needed. `, Advanced: true, Sensitive: true, + }, { + Name: "fast_list_bug_fix", + Help: `Work around a bug in Google Drive listing. + +Normally rclone will work around a bug in Google Drive when using +--fast-list (ListR) where the search "(A in parents) or (B in +parents)" returns nothing sometimes. See #3114, #4289 and +https://issuetracker.google.com/issues/149522397 + +Rclone detects this by finding no items in more than one directory +when listing and retries them as lists of individual directories. + +This means that if you have a lot of empty directories rclone will end +up listing them all individually and this can take many more API +calls. + +This flag allows the work-around to be disabled. This is **not** +recommended in normal use - only if you have a particular case you are +having trouble with like many empty directories. +`, + Advanced: true, + Default: true, }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -672,6 +694,7 @@ type Options struct { SkipShortcuts bool `config:"skip_shortcuts"` SkipDanglingShortcuts bool `config:"skip_dangling_shortcuts"` ResourceKey string `config:"resource_key"` + FastListBugFix bool `config:"fast_list_bug_fix"` Enc encoder.MultiEncoder `config:"encoding"` EnvAuth bool `config:"env_auth"` } @@ -1891,7 +1914,7 @@ 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 { + if f.opt.FastListBugFix && len(dirs) > 1 && !foundItems { 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)) }