[#612] Make listing more robust

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-07-25 16:46:36 +03:00 committed by Alex Vanin
parent 4483c6f57a
commit b2e8b1cfb3
2 changed files with 57 additions and 2 deletions

View file

@ -471,8 +471,11 @@ func (n *layer) getLatestObjectsVersions(ctx context.Context, p allObjectParams)
objects = make([]*data.ObjectInfo, 0, p.MaxKeys)
for obj := range objOutCh {
if len(objects) == p.MaxKeys { // todo reconsider stop condition
next = obj
// TODO (@kirillovdenis) : #612, #525 reconsider stop condition
// currently we handle 3 more items to reduce the likelihood of missing the last object in batch
// (potentially we can miss it because of pool of workers)
if len(objects) == p.MaxKeys+3 {
//next = obj
break
}
objects = append(objects, obj)
@ -482,6 +485,11 @@ func (n *layer) getLatestObjectsVersions(ctx context.Context, p allObjectParams)
return objects[i].Name < objects[j].Name
})
if len(objects) > p.MaxKeys {
next = objects[p.MaxKeys]
objects = objects[:p.MaxKeys]
}
return
}