[#176] blobstor: Fix maximum tree depth

Correct the calculation of maximum value of fs tree depth. Fix check
of the max depth overflow in WithShallowDepth function.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-18 14:48:47 +03:00 committed by Alex Vanin
parent f7116f27ec
commit 86385af67d
2 changed files with 2 additions and 2 deletions

View file

@ -61,7 +61,7 @@ func New(opts ...Option) *BlobStor {
// Depth is reduced to maximum value in case of overflow.
func WithShallowDepth(depth int) Option {
return func(c *cfg) {
if depth <= maxDepth {
if depth > maxDepth {
depth = maxDepth
}

View file

@ -22,7 +22,7 @@ type fsTree struct {
const dirNameLen = 2 // in bytes
var maxDepth = (hex.EncodedLen(sha256.Size) - 1) / dirNameLen
var maxDepth = (sha256.Size - 1) / dirNameLen
var errFileNotFound = errors.New("file not found")