Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

drive: fix --fast-list when using appDataFolder

Nick Craig-Wood4453fa4ba64f
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index a12c2f924..a84b46c35 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -1546,15 +1546,23 @@ func (f *Fs) listRRunner(ctx context.Context, wg *sync.WaitGroup, in <-chan list
listRSlices{dirs, paths}.Sort()
var iErr error
_, err := f.list(ctx, dirs, "", false, false, false, func(item *drive.File) bool {
- // shared with me items have no parents when at the root
- if f.opt.SharedWithMe && len(item.Parents) == 0 && len(paths) == 1 && paths[0] == "" {
- item.Parents = dirs
- }
for _, parent := range item.Parents {
- // only handle parents that are in the requested dirs list
- i := sort.SearchStrings(dirs, parent)
- if i == len(dirs) || dirs[i] != parent {
- continue
+ var i int
+ // If only one item in paths then no need to search for the ID
+ // assuming google drive is doing its job properly.
+ //
+ // Note that we at the root when len(paths) == 1 && paths[0] == ""
+ if len(paths) == 1 {
+ // don't check parents at root because
+ // - shared with me items have no parents at the root
+ // - if using a root alias, eg "root" or "appDataFolder" the ID won't match
+ i = 0
+ } else {
+ // only handle parents that are in the requested dirs list if not at root
+ i = sort.SearchStrings(dirs, parent)
+ if i == len(dirs) || dirs[i] != parent {
+ continue
+ }
}
remote := path.Join(paths[i], item.Name)
entry, err := f.itemToDirEntry(remote, item)