Our application needs a full list of the user's files and folders. We use files.list()
via the Javascript
library (essentially the same code as shown in the official API reference
as an example).
We use the "drive.files
" scope.
Examining the response to the list, we find that some files are always missing. I did various tests to understand the problem:
- The files clearly exist. They show up in the
Google Drive Webapp
and, if I explicitly request them via ID, I can get them via the API without problems. - It's reproducible, always the same files are missing.
- It is not transient. I tried a day after and still the same files are missing. I know of a few strange effects in the API that go away after some time but not this one.
- It is not a one time thing (e.g. some weird things went wrong during upload). If I repeat with a completely different Google Account again files are missing. Of a small set of 147 uploaded files in one test 4 are missed by the
files.list
call, in another test with the same 147 files on another account 23 files are missing. - It only occurs when I use the
drive.files
scope. If I relax the scope todrive
all files are returned. If look at "Details" in the Google Drive Webapp also the missing files are shown as created by our Application. So it does not seem that they lost their origin somehow. - It also occurs when I specify a search query. If I call files.list with a search term "q: modifiedDate > '2012-06-04T12:00:00'" which also should return all files, the same files are missing.
- I re-implemented the same thing as pure REST call to the API to rule out that it is an issue with the Javascript library. The error remains.
Update: I could track it down to an issue with the paging and the maxResults
parameter. If I use different values the API returns different number of items:
With maxResults=100
I get 100+100+7=207.
With maxResults=99
I get 99+99+28=226.
With maxResults=101
I get 101+101+0=202.
The last result is interesting which gave me a nextLink
indicating there are more results but the items array in the last response was actually empty. This alone might indicate a bug.
Still, this only occurs in drive.file
scope, the counts are consistent in the full drive
scope.
I'd be glad to hear ideas for a workaround. I'm aware of other ways to keep track of the users files, e.g. using the changes feed. I'm using that already but for a specific part in our application I simply need a reliable and complete list of all our application's items in a user's account.
One more note: We had other issues with the "drive.files" scope before (see Listing files with search query returns out-of-scope results (drive.files.list call, using drive.files scope)). This turned out to be an easy fix. Perhaps this issue is related.