From 86385af67d6a4bb215aa1087b3741b753a146495 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 18 Nov 2020 14:48:47 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/blobstor/blobstor.go | 2 +- pkg/local_object_storage/blobstor/fstree.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/local_object_storage/blobstor/blobstor.go b/pkg/local_object_storage/blobstor/blobstor.go index e0d4dc1e3f..ab9eeb7fd3 100644 --- a/pkg/local_object_storage/blobstor/blobstor.go +++ b/pkg/local_object_storage/blobstor/blobstor.go @@ -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 } diff --git a/pkg/local_object_storage/blobstor/fstree.go b/pkg/local_object_storage/blobstor/fstree.go index 29dd6048c0..d5d904a11a 100644 --- a/pkg/local_object_storage/blobstor/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree.go @@ -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")