Timst
Timst

Reputation: 940

Files.list yields unpredictable results

I'm using the Drive API's File List method to lists the content of a drive. There are 8 files in the drive (4 in the main folder, and another 4 in a subfolder). Last week, I used the method and successfully retrieved the 8 files.

This week however, when I tried, I first only got 5 files:

enter image description here

After accessing the drive, and trying the method again, I now get 7 files:

enter image description here

Note that this is still not correct. There should be a second "ConnectorDefinition.xml" file in the list, totaling 8.

The query is near-vanilla, with only "mimeType != 'application/vnd.google-apps.folder' and trashed = false" as "q" parameter. Removing it yield an additional result (the folder), but not the missing file (nor a trashed file that SHOULD appear now).

What can cause these differences? Nothing has changed in the sharing parameters or in the drive or account since last week.

Upvotes: 1

Views: 125

Answers (1)

pinoyyid
pinoyyid

Reputation: 22286

The spec of files.list does not guarantee that PageSize results will be returned, nor that repeated calls will return the same number of results. The only safe way to use files.list is within a loop until nextPageToken is null/undefined.

NB. This answer may or may not be the problem that you're experiencing. I'm posting it as something you need to consider and eliminate. I suggest doing a test with PageSize set to 1, so you can confirm that your code correctly iterates on nextPageToken.

Upvotes: 2

Related Questions