[#218] blobstor: Inherit the root path to Blobovnicza from BlobStor

Place the root of blobovnicza tree in a subdirectory of BlobStor with same
permissions. Abolish WithBlobovniczaRootPath and WithBlobovniczaPersmissions
options.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-30 11:51:34 +03:00 committed by Alex Vanin
parent 4c3d231e82
commit 1c81d507fd
2 changed files with 6 additions and 19 deletions

View file

@ -67,7 +67,7 @@ func TestBlobovniczas(t *testing.T) {
WithSmallSizeLimit(szLim), WithSmallSizeLimit(szLim),
WithBlobovniczaShallowWidth(width), WithBlobovniczaShallowWidth(width),
WithBlobovniczaShallowDepth(depth), WithBlobovniczaShallowDepth(depth),
WithBlobovniczaRootPath(p), WithTreeRootPath(p),
WithBlobovniczaSize(szLim), WithBlobovniczaSize(szLim),
} { } {
opt(c) opt(c)

View file

@ -3,6 +3,7 @@ package blobstor
import ( import (
"encoding/hex" "encoding/hex"
"os" "os"
"path"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
@ -34,8 +35,6 @@ type cfg struct {
blzRootPath string blzRootPath string
blzPerm os.FileMode
blzOpts []blobovnicza.Option blzOpts []blobovnicza.Option
} }
@ -49,6 +48,8 @@ const (
defaultBlzShallowWidth = 16 defaultBlzShallowWidth = 16
) )
const blobovniczaDir = "blobovnicza"
func defaultCfg() *cfg { func defaultCfg() *cfg {
return &cfg{ return &cfg{
fsTree: fsTree{ fsTree: fsTree{
@ -132,6 +133,7 @@ func WithCompressObjects(comp bool, log *logger.Logger) Option {
func WithTreeRootPath(rootDir string) Option { func WithTreeRootPath(rootDir string) Option {
return func(c *cfg) { return func(c *cfg) {
c.fsTree.RootPath = rootDir c.fsTree.RootPath = rootDir
c.blzRootPath = path.Join(rootDir, blobovniczaDir)
} }
} }
@ -140,6 +142,7 @@ func WithTreeRootPath(rootDir string) Option {
func WithTreeRootPerm(perm os.FileMode) Option { func WithTreeRootPerm(perm os.FileMode) Option {
return func(c *cfg) { return func(c *cfg) {
c.fsTree.Permissions = perm c.fsTree.Permissions = perm
c.blzOpts = append(c.blzOpts, blobovnicza.WithPermissions(perm))
} }
} }
@ -184,22 +187,6 @@ func WithBlobovniczaOpenedCacheSize(sz int) Option {
} }
} }
// WithBlobovniczaRootPath returns options to set
// system path to blobovnicza's root.
func WithBlobovniczaRootPath(root string) Option {
return func(c *cfg) {
c.blzRootPath = root
}
}
// WithBlobovniczaPersmissions returns options to specify
// permission bits of blobovnicza tree.
func WithBlobovniczaPersmissions(perm os.FileMode) Option {
return func(c *cfg) {
c.blzPerm = perm
}
}
// WithBlobovniczaSize returns option to specify maximum volume // WithBlobovniczaSize returns option to specify maximum volume
// of each blobovnicza. // of each blobovnicza.
func WithBlobovniczaSize(sz uint64) Option { func WithBlobovniczaSize(sz uint64) Option {