From 1c81d507fdf830b0be76ceed7ec5abf3f88156f1 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 30 Nov 2020 11:51:34 +0300 Subject: [PATCH] [#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 --- .../blobstor/blobovnicza_test.go | 2 +- pkg/local_object_storage/blobstor/blobstor.go | 23 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/pkg/local_object_storage/blobstor/blobovnicza_test.go b/pkg/local_object_storage/blobstor/blobovnicza_test.go index a270004870..3572b9163b 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza_test.go +++ b/pkg/local_object_storage/blobstor/blobovnicza_test.go @@ -67,7 +67,7 @@ func TestBlobovniczas(t *testing.T) { WithSmallSizeLimit(szLim), WithBlobovniczaShallowWidth(width), WithBlobovniczaShallowDepth(depth), - WithBlobovniczaRootPath(p), + WithTreeRootPath(p), WithBlobovniczaSize(szLim), } { opt(c) diff --git a/pkg/local_object_storage/blobstor/blobstor.go b/pkg/local_object_storage/blobstor/blobstor.go index 5c1629ef6f..0dfb19a251 100644 --- a/pkg/local_object_storage/blobstor/blobstor.go +++ b/pkg/local_object_storage/blobstor/blobstor.go @@ -3,6 +3,7 @@ package blobstor import ( "encoding/hex" "os" + "path" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/util/logger" @@ -34,8 +35,6 @@ type cfg struct { blzRootPath string - blzPerm os.FileMode - blzOpts []blobovnicza.Option } @@ -49,6 +48,8 @@ const ( defaultBlzShallowWidth = 16 ) +const blobovniczaDir = "blobovnicza" + func defaultCfg() *cfg { return &cfg{ fsTree: fsTree{ @@ -132,6 +133,7 @@ func WithCompressObjects(comp bool, log *logger.Logger) Option { func WithTreeRootPath(rootDir string) Option { return func(c *cfg) { 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 { return func(c *cfg) { 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 // of each blobovnicza. func WithBlobovniczaSize(sz uint64) Option {