From 34a259d5c050dcbbfeef9bc8da823ffb557410c2 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 30 Nov 2020 16:49:50 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/blobstor/blobovnicza.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/local_object_storage/blobstor/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovnicza.go index f694eb5b..daeb5ce2 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovnicza.go @@ -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...)) }, )