bucketManager.listPrefix 查询结果不准确
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 590
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
我使用bucketManager.listPrefix方法查询空间里符合前缀条件的文件列表,但是在参数一样的前提下,偶现查询结果不准确的场景。
查询代码如下:
/**
* 根据分页信息和前缀获取文件列表
* @param query
*/
async queryFiles (query) {
const { prefix = 'monitoring/assets/', pageNo, pageSize } = query || {}
const options = {
limit: 10000, // 每次返回的文件数量上限
prefix,
}
const findFiles = new Promise((resolve, reject) => {
bucketManager.listPrefix(bucket, options, (err, respBody, respInfo) => {
if (err) {
console.log('查询失败', err)
throw err
}
const { marker } = respBody
console.log(marker, prefix, pageNo, pageSize)
if (respInfo.statusCode === 200) {
// 因为 pageNo 是从 1 开始的所以简单做下分页
const newItems = respBody?.items.sort((a, b) => b?.putTime - a?.putTime)
const data = newItems?.slice((pageNo - 1) * pageSize, pageNo * pageSize)
const response = {
data: data || [],
pageSize: Number(pageSize) || 0,
pageNo: Number(pageNo) || 0,
total: respBody?.items?.length || 0,
}
resolve(response)
} else {
reject(respInfo)
}
})
})
const result: any = await findFiles
return result
}
查询结果如下:
异常情况:

正常情况:

传入的bucket一直为空, options不变,得到的结果很奇怪,而且我去七牛官方查看我空间的文件列表,发现也出现查询接口返回为空的情况。
异常结果:

正常情况:

所以请问这查询是有问题么,还是我哪里姿势不对?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported queryFiles usage of bucketManager.listPrefix, keeping the bucket and options unchanged while comparing repeated responses. Check the returned respBody.items, marker, and respInfo.statusCode against the reported empty and inconsistent results. Done means the cause is reproducible and the issue has a documented correction or confirmed SDK behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100