[#220] blobstor: Support zero shallow depth of blobovnicza tree

There is a need to support single blobovnicza in blobovnicza tree. This can
be achieved with a width of 1, and a depth of 0 or 1. With depth = 1 one
redundant directory is created, inside which there is a blobovnicza. If the
depth is zero, the blobobnivza will be in the root path. Fix negative
capacity in iterateDeepest method with zero depth.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-30 16:49:50 +03:00 committed by Alex Vanin
parent 8bff073061
commit 34a259d5c0

View file

@ -463,10 +463,15 @@ func (b *blobovniczas) iterateSortedLeaves(addr *objectSDK.Address, f func(strin
// iterator over directories with blobovniczas sorted by weight.
func (b *blobovniczas) iterateDeepest(addr *objectSDK.Address, f func(string) (bool, error)) error {
depth := b.blzShallowDepth
if depth > 0 {
depth--
}
_, err := b.iterateSorted(
addr,
make([]string, 0, b.blzShallowDepth-1),
b.blzShallowDepth-1,
make([]string, 0, depth),
depth,
func(p []string) (bool, error) { return f(path.Join(p...)) },
)