files.list()在父级搜索q ='FOLDER_ID'时返回不完整列表 [英] files.list() returns an incomplete list when searching for q='FOLDER_ID' in parent
问题描述
为此,我使用file.list()和 q ='FOLDER_ID'in parent和trashed = false
,FOLDER_ID是我感兴趣的文件夹的ID。当我处理结果时,我跟踪所有文件夹从该请求返回,然后使用 q
参数中的新文件夹重复files.list()调用。我使用或
在一个请求中合并多个文件夹,并继续重复此操作,直到没有新文件夹返回。
例子:
初始请求: 有时候会返回所有文件夹以及其他时间。如果我删除 q =('FOLDER_ID'in parent)and trashed = false
>
所有后续请求: q =(父母中的'FOLDER_ID_1',父母中的'FOLDER_ID_2'或父母中的'FOLDER_ID_3'...)和垃圾邮件=假$ c $ (有关如何创建查询的详细信息,请参阅驱动REST API - 搜索文件)
q
参数,则不会发生这种情况,因为每个文件和文件夹都会返回,而且都不会丢失。 q
的请求似乎是修复了问题。下一次运行我的应用程序并使用 q
时,将返回所有正确的文件夹。
其他信息:
-
这不是权限问题,我使用
drive.readonly $ c $
它不是
pageSize
问题,因为我尝试了不同的值并获得了不同的值结果。
这不是一个
pageToken
的问题,因为我一定会再次发送请求当它存在时给出nextPageToken
。 -
我在一个小于4000的文件夹上运行它后裔文件夹和25,000个后代文件。
我觉得这必须是一个相关的错误在单个请求中使用 q
参数中的多个文件夹,考虑到我可以执行完全相同的过程,并且看起来会随机得到不同的结果。
I在查找给定用户拥有的所有文件时发现类似问题,例如:
'example.user@company.com'in owner和trashed = false
我有大约5000个文件,通常我可以通过分页遍历所有文件。然而有些日子(比如今天)我只用上面的查询得到< 100的结果。当我重写我的代码以获取给定父ID的文件,然后递归遍历子文件夹时,我将获取所有文件。之后原来的查询又成功了。
它在google-drive服务器上看起来像是一种缓存问题。
I am trying to gather all of the files and folders that are descendants of a given folder.
To do this I use file.list() with q="'FOLDER_ID' in parent" and trashed=false
with FOLDER_ID being the ID of the folder I am interested in. As I process the results I keep track of all of the folders that get returned from this request and then repeat the files.list() call using the new folders in the q
parameter. I combine multiple folders in one request by using or
and continue to repeat this until no new folders are returned.
Example:
Initial Request: q="('FOLDER_ID' in parent) and trashed=false"
All Subsequent Requests: q="('FOLDER_ID_1' in parent or 'FOLDER_ID_2' in parent or 'FOLDER_ID_3' in parent ...) and trashed=false"
(For more information about how to create queries see Drive REST API - Search for Files)
Sometimes this returns all the folders it should and other times some are left out. This doesn't happen if I remove the q
parameter as every single file and folder are returned, none are missing.
After some testing/trial and error, I discovered that if I am not receiving all the folders I should be, sending a request with no q
seems to "fix" the problem. The next time I run my application and it uses q
, all the correct folders do get returned.
Other Information:
It is not a permissions issue, I am using
drive.readonly
It is not a
pageSize
issue as I have tried different values for this and get different results.It is not a
pageToken
issue as I make sure to send a request again with the givennextPageToken
when it exists.I am running this on a folder that has a little under 4,000 descendant folders in it and a little under 25,000 descendant files in it.
I feel like this must be a bug related to using multiple folders in the q
parameter in a single request, considering that I can perform the exact same process and will get different results seemingly randomly.
I found a similar issue when looking for all files a given user owns, eg:
'example.user@company.com' in owners and trashed=false
I have about 5000 files and usually I can iterate through all of them via pagination. Some days however (like today) I only get <100 results with the query above. When I rewrite my code to fetch files for a given parent-ID and then recursively iterate through the sub-folders, I will get all files. Afterwards the original query succeeds again as well.
It looks like some kind of caching issue on the google-drive server to me.
这篇关于files.list()在父级搜索q ='FOLDER_ID'时返回不完整列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!