From 5c69e190166b4d7f8a49e25c36b7748d1467f092 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 26 Sep 2022 19:38:03 +0300 Subject: [PATCH] [#1770] fstree: Depth parameter `int` -> `uint64` Negative values have no sense. On the other hand it differs from the blobovnicza's configuration and prevents unification. Signed-off-by: Pavel Karpy --- .../config/engine/shard/blobstor/fstree/config.go | 6 +++--- pkg/local_object_storage/blobstor/fstree/fstree.go | 6 +++--- pkg/local_object_storage/blobstor/fstree/option.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go index 5b9f22af6..8be8876ce 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go @@ -26,14 +26,14 @@ func (x *Config) Type() string { // // Returns DepthDefault if the value is out of // [1:fstree.MaxDepth] range. -func (x *Config) Depth() int { - d := config.IntSafe( +func (x *Config) Depth() uint64 { + d := config.UintSafe( (*config.Config)(x), "depth", ) if d >= 1 && d <= fstree.MaxDepth { - return int(d) + return d } return DepthDefault diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index d2db1d8d7..25674d640 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -23,7 +23,7 @@ type FSTree struct { Info *compression.Config - Depth int + Depth uint64 DirNameLen int readOnly bool @@ -96,7 +96,7 @@ func (t *FSTree) Iterate(prm common.IteratePrm) (common.IterateRes, error) { return common.IterateRes{}, t.iterate(0, []string{t.RootPath}, prm) } -func (t *FSTree) iterate(depth int, curPath []string, prm common.IteratePrm) error { +func (t *FSTree) iterate(depth uint64, curPath []string, prm common.IteratePrm) error { curName := strings.Join(curPath[1:], "") des, err := os.ReadDir(filepath.Join(curPath...)) if err != nil { @@ -172,7 +172,7 @@ func (t *FSTree) treePath(addr oid.Address) string { dirs := make([]string, 0, t.Depth+1+1) // 1 for root, 1 for file dirs = append(dirs, t.RootPath) - for i := 0; i < t.Depth; i++ { + for i := 0; uint64(i) < t.Depth; i++ { dirs = append(dirs, sAddr[:t.DirNameLen]) sAddr = sAddr[t.DirNameLen:] } diff --git a/pkg/local_object_storage/blobstor/fstree/option.go b/pkg/local_object_storage/blobstor/fstree/option.go index fd3cc272c..2c2e55bd0 100644 --- a/pkg/local_object_storage/blobstor/fstree/option.go +++ b/pkg/local_object_storage/blobstor/fstree/option.go @@ -6,7 +6,7 @@ import ( type Option func(*FSTree) -func WithDepth(d int) Option { +func WithDepth(d uint64) Option { return func(f *FSTree) { f.Depth = d }