drive: fix --fast-list when using appDataFolder
In listings if the ID `appDataFolder` is used to list a directory the parents of the items returned have the actual ID instead the alias `appDataFolder`. This confused the ListR routine into ignoring all these items. This change makes the listing routine accept all parent IDs returned if there was only one ID in the query. This fixes the `appDataFolder` problem. This means we are relying on Google Drive to only return the items we asked for which is probably OK. Fixes #3851
This commit is contained in:
parent
540fd3f173
commit
4453fa4ba6
1 changed files with 16 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue