[#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 <carpawell@nspcc.ru>
This commit is contained in:
parent
4aa4694152
commit
5c69e19016
3 changed files with 7 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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:]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue