diff --git a/cmd/neofs-adm/internal/modules/config/config.go b/cmd/neofs-adm/internal/modules/config/config.go index 438a112ade..3101dac638 100644 --- a/cmd/neofs-adm/internal/modules/config/config.go +++ b/cmd/neofs-adm/internal/modules/config/config.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "os" - "path" "path/filepath" "text/template" @@ -51,7 +50,7 @@ func initConfig(cmd *cobra.Command, args []string) error { return nil } - pathDir := path.Dir(configPath) + pathDir := filepath.Dir(configPath) err = os.MkdirAll(pathDir, 0700) if err != nil { return fmt.Errorf("create dir %s: %w", pathDir, err) @@ -97,7 +96,7 @@ func defaultConfigPath() (string, error) { return "", fmt.Errorf("getting home dir path: %w", err) } - return path.Join(home, ".neofs", "adm", "config.yml"), nil + return filepath.Join(home, ".neofs", "adm", "config.yml"), nil } // generateConfigExample builds .yml representation of the config file. It is @@ -122,7 +121,7 @@ func generateConfigExample(appDir string, credSize int) (string, error) { if err != nil { return "", fmt.Errorf("making absolute path for %s: %w", appDir, err) } - tmpl.AlphabetDir = path.Join(appDir, "alphabet-wallets") + tmpl.AlphabetDir = filepath.Join(appDir, "alphabet-wallets") var i innerring.GlagoliticLetter for i = 0; i < innerring.GlagoliticLetter(credSize); i++ { diff --git a/cmd/neofs-adm/internal/modules/config/config_test.go b/cmd/neofs-adm/internal/modules/config/config_test.go index c0671c2b57..46d8230776 100644 --- a/cmd/neofs-adm/internal/modules/config/config_test.go +++ b/cmd/neofs-adm/internal/modules/config/config_test.go @@ -2,7 +2,7 @@ package config import ( "bytes" - "path" + "path/filepath" "testing" "github.com/nspcc-dev/neofs-node/pkg/innerring" @@ -25,7 +25,7 @@ func TestGenerateConfigExample(t *testing.T) { require.NoError(t, v.ReadConfig(bytes.NewBufferString(configText))) require.Equal(t, "https://neo.rpc.node:30333", v.GetString("rpc-endpoint")) - require.Equal(t, path.Join(appDir, "alphabet-wallets"), v.GetString("alphabet-wallets")) + require.Equal(t, filepath.Join(appDir, "alphabet-wallets"), v.GetString("alphabet-wallets")) require.Equal(t, 67108864, v.GetInt("network.max_object_size")) require.Equal(t, 240, v.GetInt("network.epoch_duration")) require.Equal(t, 100000000, v.GetInt("network.basic_income_rate")) diff --git a/cmd/neofs-adm/internal/modules/morph/generate.go b/cmd/neofs-adm/internal/modules/morph/generate.go index b40a2a44ac..c9a139ce39 100644 --- a/cmd/neofs-adm/internal/modules/morph/generate.go +++ b/cmd/neofs-adm/internal/modules/morph/generate.go @@ -3,7 +3,7 @@ package morph import ( "errors" "fmt" - "path" + "path/filepath" "github.com/nspcc-dev/neo-go/cli/input" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" @@ -62,7 +62,7 @@ func initializeWallets(walletDir string, size int) ([]string, error) { return nil, fmt.Errorf("can't fetch password: %w", err) } - p := path.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") + p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") // TODO(@fyrchik): file is created with 0666 permissions, consider changing. w, err := wallet.NewWallet(p) if err != nil { diff --git a/cmd/neofs-adm/internal/modules/morph/generate_test.go b/cmd/neofs-adm/internal/modules/morph/generate_test.go index e24dc8cb76..d54d538cc4 100644 --- a/cmd/neofs-adm/internal/modules/morph/generate_test.go +++ b/cmd/neofs-adm/internal/modules/morph/generate_test.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "math/rand" "os" - "path" + "path/filepath" "strconv" "testing" @@ -42,7 +42,7 @@ func TestGenerateAlphabet(t *testing.T) { }) t.Run("missing directory", func(t *testing.T) { buf.Reset() - dir := path.Join(os.TempDir(), "notexist."+strconv.FormatUint(rand.Uint64(), 10)) + dir := filepath.Join(os.TempDir(), "notexist."+strconv.FormatUint(rand.Uint64(), 10)) v.Set(alphabetWalletsFlag, dir) require.NoError(t, cmd.Flags().Set(alphabetSizeFlag, "1")) buf.WriteString("pass\r") @@ -59,7 +59,7 @@ func TestGenerateAlphabet(t *testing.T) { require.NoError(t, generateAlphabetCreds(cmd, nil)) for i := uint64(0); i < size; i++ { - p := path.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") + p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") w, err := wallet.NewWalletFromFile(p) require.NoError(t, err, "wallet doesn't exist") require.Equal(t, 3, len(w.Accounts), "not all accounts were created") @@ -91,7 +91,7 @@ func setupTestTerminal(t *testing.T) *bytes.Buffer { } func newTempDir(t *testing.T) string { - dir := path.Join(os.TempDir(), "neofs-adm.test."+strconv.FormatUint(rand.Uint64(), 10)) + dir := filepath.Join(os.TempDir(), "neofs-adm.test."+strconv.FormatUint(rand.Uint64(), 10)) require.NoError(t, os.Mkdir(dir, os.ModePerm)) t.Cleanup(func() { require.NoError(t, os.RemoveAll(dir)) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index a95371b237..04accf7f03 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" "io/ioutil" - "path" + "path/filepath" "strings" "time" @@ -192,7 +192,7 @@ loop: wallets := make([]*wallet.Wallet, size) for i := 0; i < size; i++ { - p := path.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") + p := filepath.Join(walletDir, innerring.GlagoliticLetter(i).String()+".json") w, err := wallet.NewWalletFromFile(p) if err != nil { return nil, fmt.Errorf("can't open wallet: %w", err) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 871f649900..c994a929db 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -9,7 +9,7 @@ import ( "io" "io/ioutil" "os" - "path" + "path/filepath" "strings" "github.com/nspcc-dev/neo-go/pkg/core/native" @@ -370,11 +370,11 @@ func (c *initializeContext) readContracts(names []string) error { if c.ContractPath != "" && fi.IsDir() { for _, ctrName := range names { cs := new(contractState) - cs.RawNEF, err = ioutil.ReadFile(path.Join(c.ContractPath, ctrName, ctrName+"_contract.nef")) + cs.RawNEF, err = ioutil.ReadFile(filepath.Join(c.ContractPath, ctrName, ctrName+"_contract.nef")) if err != nil { return fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err) } - cs.RawManifest, err = ioutil.ReadFile(path.Join(c.ContractPath, ctrName, "config.json")) + cs.RawManifest, err = ioutil.ReadFile(filepath.Join(c.ContractPath, ctrName, "config.json")) if err != nil { return fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err) } @@ -449,8 +449,8 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr break } - dir, _ := path.Split(h.Name) - ctrName := path.Base(dir) + dir, _ := filepath.Split(h.Name) + ctrName := filepath.Base(dir) cs, ok := m[ctrName] if !ok { @@ -458,7 +458,7 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr } switch { - case strings.HasSuffix(h.Name, path.Join(ctrName, ctrName+"_contract.nef")): + case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")): cs.RawNEF, err = ioutil.ReadAll(r) if err != nil { return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err) diff --git a/cmd/neofs-cli/modules/key_test.go b/cmd/neofs-cli/modules/key_test.go index ebb91730f2..a7e129e31f 100644 --- a/cmd/neofs-cli/modules/key_test.go +++ b/cmd/neofs-cli/modules/key_test.go @@ -5,7 +5,6 @@ import ( "errors" "io/ioutil" "os" - "path" "path/filepath" "testing" @@ -20,7 +19,7 @@ import ( func Test_getKey(t *testing.T) { dir := t.TempDir() - wallPath := path.Join(dir, "wallet.json") + wallPath := filepath.Join(dir, "wallet.json") w, err := wallet.NewWallet(wallPath) require.NoError(t, err) @@ -37,7 +36,7 @@ func Test_getKey(t *testing.T) { require.NoError(t, w.Save()) w.Close() - keyPath := path.Join(dir, "binary.key") + keyPath := filepath.Join(dir, "binary.key") rawKey, err := keys.NewPrivateKey() require.NoError(t, err) require.NoError(t, ioutil.WriteFile(keyPath, rawKey.Bytes(), os.ModePerm)) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 5002f4637d..219753151f 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -3,7 +3,7 @@ package main import ( "context" "net" - "path" + "path/filepath" "sync" "time" @@ -390,7 +390,7 @@ func initShardOptions(c *cfg) { metaPath := metabaseCfg.Path() metaPerm := metabaseCfg.Perm() - fatalOnErr(util.MkdirAllX(path.Dir(metaPath), metaPerm)) + fatalOnErr(util.MkdirAllX(filepath.Dir(metaPath), metaPerm)) opts = append(opts, []shard.Option{ shard.WithLogger(c.log), diff --git a/pkg/local_object_storage/blobovnicza/control.go b/pkg/local_object_storage/blobovnicza/control.go index 72e2d364b5..759325f1cd 100644 --- a/pkg/local_object_storage/blobovnicza/control.go +++ b/pkg/local_object_storage/blobovnicza/control.go @@ -2,7 +2,7 @@ package blobovnicza import ( "fmt" - "path" + "path/filepath" "github.com/nspcc-dev/neofs-node/pkg/util" "go.etcd.io/bbolt" @@ -21,7 +21,7 @@ func (b *Blobovnicza) Open() error { var err error if !b.boltOptions.ReadOnly { - err = util.MkdirAllX(path.Dir(b.path), b.perm) + err = util.MkdirAllX(filepath.Dir(b.path), b.perm) if err != nil { return err } diff --git a/pkg/local_object_storage/blobstor/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovnicza.go index c05accc269..e067d82360 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovnicza.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" "fmt" - "path" + "path/filepath" "strconv" "sync" @@ -88,7 +88,7 @@ var errPutFailed = errors.New("could not save the object in any blobovnicza") func newBlobovniczaTree(c *cfg) (blz *blobovniczas) { cache, err := simplelru.NewLRU(c.openedCacheSize, func(key interface{}, value interface{}) { - if _, ok := blz.active[path.Dir(key.(string))]; ok { + if _, ok := blz.active[filepath.Dir(key.(string))]; ok { return } else if err := value.(*blobovnicza.Blobovnicza).Close(); err != nil { c.log.Error("could not close Blobovnicza", @@ -156,7 +156,7 @@ func (b *blobovniczas) put(addr *objectSDK.Address, data []byte) (*blobovnicza.I // check if blobovnicza is full if errors.Is(err, blobovnicza.ErrFull) { b.log.Debug("blobovnicza overflowed", - zap.String("path", path.Join(p, u64ToHexString(active.ind))), + zap.String("path", filepath.Join(p, u64ToHexString(active.ind))), ) if err := b.updateActive(p, &active.ind); err != nil { @@ -172,14 +172,14 @@ func (b *blobovniczas) put(addr *objectSDK.Address, data []byte) (*blobovnicza.I } b.log.Debug("could not put object to active blobovnicza", - zap.String("path", path.Join(p, u64ToHexString(active.ind))), + zap.String("path", filepath.Join(p, u64ToHexString(active.ind))), zap.String("error", err.Error()), ) return false, nil } - p = path.Join(p, u64ToHexString(active.ind)) + p = filepath.Join(p, u64ToHexString(active.ind)) id = blobovnicza.NewIDFromBytes([]byte(p)) @@ -217,7 +217,7 @@ func (b *blobovniczas) get(prm *GetSmallPrm) (res *GetSmallRes, err error) { activeCache := make(map[string]struct{}) err = b.iterateSortedLeaves(prm.addr, func(p string) (bool, error) { - dirPath := path.Dir(p) + dirPath := filepath.Dir(p) _, ok := activeCache[dirPath] @@ -267,7 +267,7 @@ func (b *blobovniczas) delete(prm *DeleteSmallPrm) (res *DeleteSmallRes, err err activeCache := make(map[string]struct{}) err = b.iterateSortedLeaves(prm.addr, func(p string) (bool, error) { - dirPath := path.Dir(p) + dirPath := filepath.Dir(p) // don't process active blobovnicza of the level twice _, ok := activeCache[dirPath] @@ -319,7 +319,7 @@ func (b *blobovniczas) getRange(prm *GetRangeSmallPrm) (res *GetRangeSmallRes, e activeCache := make(map[string]struct{}) err = b.iterateSortedLeaves(prm.addr, func(p string) (bool, error) { - dirPath := path.Dir(p) + dirPath := filepath.Dir(p) _, ok := activeCache[dirPath] @@ -351,7 +351,7 @@ func (b *blobovniczas) getRange(prm *GetRangeSmallPrm) (res *GetRangeSmallRes, e // // returns no error if object was removed from some blobovnicza of the same level. func (b *blobovniczas) deleteObjectFromLevel(prm *blobovnicza.DeletePrm, blzPath string, tryActive bool, dp *DeleteSmallPrm) (*DeleteSmallRes, error) { - lvlPath := path.Dir(blzPath) + lvlPath := filepath.Dir(blzPath) log := b.log.With( zap.String("path", blzPath), @@ -394,7 +394,7 @@ func (b *blobovniczas) deleteObjectFromLevel(prm *blobovnicza.DeletePrm, blzPath // check if it makes sense to try to open the blob // (blobovniczas "after" the active one are empty anyway, // and it's pointless to open them). - if u64FromHexString(path.Base(blzPath)) > active.ind { + if u64FromHexString(filepath.Base(blzPath)) > active.ind { log.Debug("index is too big") return nil, object.ErrNotFound } @@ -412,7 +412,7 @@ func (b *blobovniczas) deleteObjectFromLevel(prm *blobovnicza.DeletePrm, blzPath // // returns error if object could not be read from any blobovnicza of the same level. func (b *blobovniczas) getObjectFromLevel(prm *blobovnicza.GetPrm, blzPath string, tryActive bool) (*GetSmallRes, error) { - lvlPath := path.Dir(blzPath) + lvlPath := filepath.Dir(blzPath) log := b.log.With( zap.String("path", blzPath), @@ -456,7 +456,7 @@ func (b *blobovniczas) getObjectFromLevel(prm *blobovnicza.GetPrm, blzPath strin // check if it makes sense to try to open the blob // (blobovniczas "after" the active one are empty anyway, // and it's pointless to open them). - if u64FromHexString(path.Base(blzPath)) > active.ind { + if u64FromHexString(filepath.Base(blzPath)) > active.ind { log.Debug("index is too big") return nil, object.ErrNotFound } @@ -474,7 +474,7 @@ func (b *blobovniczas) getObjectFromLevel(prm *blobovnicza.GetPrm, blzPath strin // // returns error if object could not be read from any blobovnicza of the same level. func (b *blobovniczas) getRangeFromLevel(prm *GetRangeSmallPrm, blzPath string, tryActive bool) (*GetRangeSmallRes, error) { - lvlPath := path.Dir(blzPath) + lvlPath := filepath.Dir(blzPath) log := b.log.With( zap.String("path", blzPath), @@ -528,7 +528,7 @@ func (b *blobovniczas) getRangeFromLevel(prm *GetRangeSmallPrm, blzPath string, // check if it makes sense to try to open the blob // (blobovniczas "after" the active one are empty anyway, // and it's pointless to open them). - if u64FromHexString(path.Base(blzPath)) > active.ind { + if u64FromHexString(filepath.Base(blzPath)) > active.ind { log.Debug("index is too big") return nil, object.ErrNotFound } @@ -653,7 +653,7 @@ func (b *blobovniczas) iterateSortedLeaves(addr *objectSDK.Address, f func(strin addr, make([]string, 0, b.blzShallowDepth), b.blzShallowDepth, - func(p []string) (bool, error) { return f(path.Join(p...)) }, + func(p []string) (bool, error) { return f(filepath.Join(p...)) }, ) return err @@ -670,7 +670,7 @@ func (b *blobovniczas) iterateDeepest(addr *objectSDK.Address, f func(string) (b addr, make([]string, 0, depth), depth, - func(p []string) (bool, error) { return f(path.Join(p...)) }, + func(p []string) (bool, error) { return f(filepath.Join(p...)) }, ) return err @@ -680,7 +680,7 @@ func (b *blobovniczas) iterateDeepest(addr *objectSDK.Address, f func(string) (b func (b *blobovniczas) iterateSorted(addr *objectSDK.Address, curPath []string, execDepth uint64, f func([]string) (bool, error)) (bool, error) { indices := indexSlice(b.blzShallowWidth) - hrw.SortSliceByValue(indices, addressHash(addr, path.Join(curPath...))) + hrw.SortSliceByValue(indices, addressHash(addr, filepath.Join(curPath...))) exec := uint64(len(curPath)) == execDepth @@ -754,7 +754,7 @@ func (b *blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex } var err error - if active.blz, err = b.openBlobovnicza(path.Join(p, u64ToHexString(active.ind))); err != nil { + if active.blz, err = b.openBlobovnicza(filepath.Join(p, u64ToHexString(active.ind))); err != nil { return active, err } @@ -773,7 +773,7 @@ func (b *blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex b.active[p] = active b.log.Debug("blobovnicza successfully activated", - zap.String("path", path.Join(p, u64ToHexString(active.ind))), + zap.String("path", filepath.Join(p, u64ToHexString(active.ind))), ) return active, nil @@ -887,7 +887,7 @@ func (b *blobovniczas) openBlobovnicza(p string) (*blobovnicza.Blobovnicza, erro } blz := blobovnicza.New(append(b.blzOpts, - blobovnicza.WithPath(path.Join(b.blzRootPath, p)), + blobovnicza.WithPath(filepath.Join(b.blzRootPath, p)), )...) if err := blz.Open(); err != nil { diff --git a/pkg/local_object_storage/blobstor/blobstor.go b/pkg/local_object_storage/blobstor/blobstor.go index 5c927b0706..2a30279ffa 100644 --- a/pkg/local_object_storage/blobstor/blobstor.go +++ b/pkg/local_object_storage/blobstor/blobstor.go @@ -3,7 +3,7 @@ package blobstor import ( "encoding/hex" "io/fs" - "path" + "path/filepath" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" @@ -132,7 +132,7 @@ func WithUncompressableContentTypes(values []string) Option { func WithRootPath(rootDir string) Option { return func(c *cfg) { c.fsTree.RootPath = rootDir - c.blzRootPath = path.Join(rootDir, blobovniczaDir) + c.blzRootPath = filepath.Join(rootDir, blobovniczaDir) } } diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index a4d7a4c8f4..6e5c8b0d99 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -6,7 +6,6 @@ import ( "fmt" "io/fs" "os" - "path" "path/filepath" "strings" @@ -94,7 +93,7 @@ func (t *FSTree) Iterate(prm *IterationPrm) error { func (t *FSTree) iterate(depth int, curPath []string, prm *IterationPrm) error { curName := strings.Join(curPath[1:], "") - des, err := os.ReadDir(path.Join(curPath...)) + des, err := os.ReadDir(filepath.Join(curPath...)) if err != nil { if prm.ignoreErrors { return nil @@ -127,7 +126,7 @@ func (t *FSTree) iterate(depth int, curPath []string, prm *IterationPrm) error { continue } - data, err := os.ReadFile(path.Join(curPath...)) + data, err := os.ReadFile(filepath.Join(curPath...)) if err != nil { if prm.ignoreErrors { continue @@ -157,7 +156,7 @@ func (t *FSTree) treePath(addr *objectSDK.Address) string { dirs = append(dirs, sAddr) - return path.Join(dirs...) + return filepath.Join(dirs...) } // Delete removes object with the specified address from storage. @@ -187,7 +186,7 @@ func (t *FSTree) Exists(addr *objectSDK.Address) (string, error) { func (t *FSTree) Put(addr *objectSDK.Address, data []byte) error { p := t.treePath(addr) - if err := util.MkdirAllX(path.Dir(p), t.Permissions); err != nil { + if err := util.MkdirAllX(filepath.Dir(p), t.Permissions); err != nil { return err } diff --git a/pkg/local_object_storage/blobstor/fstree/fstree_test.go b/pkg/local_object_storage/blobstor/fstree/fstree_test.go index 59fb084d8f..1d6f74a3e6 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree_test.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree_test.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "errors" "os" - "path" "path/filepath" "testing" @@ -43,7 +42,7 @@ func TestAddressToString(t *testing.T) { } func TestFSTree(t *testing.T) { - tmpDir := path.Join(os.TempDir(), "neofs.fstree.test") + tmpDir := filepath.Join(os.TempDir(), "neofs.fstree.test") require.NoError(t, os.Mkdir(tmpDir, os.ModePerm)) t.Cleanup(func() { require.NoError(t, os.RemoveAll(tmpDir)) }) diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index 67c7a508ec..6565cd440b 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -4,7 +4,7 @@ import ( "crypto/sha256" "fmt" "math/rand" - "path" + "path/filepath" "sync" "testing" @@ -57,13 +57,13 @@ func testNewShard(t *testing.T, id int) *shard.Shard { shard.WithID(sid), shard.WithLogger(zap.L()), shard.WithBlobStorOptions( - blobstor.WithRootPath(path.Join(t.Name(), fmt.Sprintf("%d.blobstor", id))), + blobstor.WithRootPath(filepath.Join(t.Name(), fmt.Sprintf("%d.blobstor", id))), blobstor.WithBlobovniczaShallowWidth(2), blobstor.WithBlobovniczaShallowDepth(2), blobstor.WithRootPerm(0700), ), shard.WithMetaBaseOptions( - meta.WithPath(path.Join(t.Name(), fmt.Sprintf("%d.metabase", id))), + meta.WithPath(filepath.Join(t.Name(), fmt.Sprintf("%d.metabase", id))), meta.WithPermissions(0700), )) diff --git a/pkg/local_object_storage/metabase/control.go b/pkg/local_object_storage/metabase/control.go index e876d7cb85..638a00404b 100644 --- a/pkg/local_object_storage/metabase/control.go +++ b/pkg/local_object_storage/metabase/control.go @@ -2,7 +2,7 @@ package meta import ( "fmt" - "path" + "path/filepath" "github.com/nspcc-dev/neofs-node/pkg/util" "go.etcd.io/bbolt" @@ -11,7 +11,7 @@ import ( // Open boltDB instance for metabase. func (db *DB) Open() error { - err := util.MkdirAllX(path.Dir(db.info.Path), db.info.Permission) + err := util.MkdirAllX(filepath.Dir(db.info.Path), db.info.Permission) if err != nil { return fmt.Errorf("can't create dir %s for metabase: %w", db.info.Path, err) } diff --git a/pkg/local_object_storage/shard/control_test.go b/pkg/local_object_storage/shard/control_test.go index e2a3d902b5..7e32f83a2b 100644 --- a/pkg/local_object_storage/shard/control_test.go +++ b/pkg/local_object_storage/shard/control_test.go @@ -2,7 +2,7 @@ package shard import ( "os" - "path" + "path/filepath" "testing" "github.com/nspcc-dev/neofs-node/pkg/core/object" @@ -19,7 +19,7 @@ func TestRefillMetabase(t *testing.T) { defer os.RemoveAll(p) blobOpts := []blobstor.Option{ - blobstor.WithRootPath(path.Join(p, "blob")), + blobstor.WithRootPath(filepath.Join(p, "blob")), blobstor.WithBlobovniczaShallowWidth(1), blobstor.WithBlobovniczaShallowDepth(1), } @@ -27,7 +27,7 @@ func TestRefillMetabase(t *testing.T) { sh := New( WithBlobStorOptions(blobOpts...), WithMetaBaseOptions( - meta.WithPath(path.Join(p, "meta")), + meta.WithPath(filepath.Join(p, "meta")), ), ) @@ -141,7 +141,7 @@ func TestRefillMetabase(t *testing.T) { sh = New( WithBlobStorOptions(blobOpts...), WithMetaBaseOptions( - meta.WithPath(path.Join(p, "meta_restored")), + meta.WithPath(filepath.Join(p, "meta_restored")), ), ) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index 948a5f11d0..7d00e2065e 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -4,7 +4,7 @@ import ( "crypto/sha256" "math/rand" "os" - "path" + "path/filepath" "strings" "testing" @@ -34,27 +34,27 @@ func newShard(t testing.TB, enableWriteCache bool) *shard.Shard { func newCustomShard(t testing.TB, rootPath string, enableWriteCache bool, wcOpts []writecache.Option, bsOpts []blobstor.Option) *shard.Shard { if enableWriteCache { - rootPath = path.Join(rootPath, "wc") + rootPath = filepath.Join(rootPath, "wc") } else { - rootPath = path.Join(rootPath, "nowc") + rootPath = filepath.Join(rootPath, "nowc") } opts := []shard.Option{ shard.WithLogger(zap.L()), shard.WithBlobStorOptions( append([]blobstor.Option{ - blobstor.WithRootPath(path.Join(rootPath, "blob")), + blobstor.WithRootPath(filepath.Join(rootPath, "blob")), blobstor.WithBlobovniczaShallowWidth(2), blobstor.WithBlobovniczaShallowDepth(2), }, bsOpts...)..., ), shard.WithMetaBaseOptions( - meta.WithPath(path.Join(rootPath, "meta")), + meta.WithPath(filepath.Join(rootPath, "meta")), ), shard.WithWriteCache(enableWriteCache), shard.WithWriteCacheOptions( append( - []writecache.Option{writecache.WithPath(path.Join(rootPath, "wcache"))}, + []writecache.Option{writecache.WithPath(filepath.Join(rootPath, "wcache"))}, wcOpts...)..., ), } diff --git a/pkg/local_object_storage/writecache/util.go b/pkg/local_object_storage/writecache/util.go index 62e7ca7485..8ff30b3620 100644 --- a/pkg/local_object_storage/writecache/util.go +++ b/pkg/local_object_storage/writecache/util.go @@ -2,14 +2,14 @@ package writecache import ( "os" - "path" + "path/filepath" "go.etcd.io/bbolt" ) // OpenDB opens BoltDB instance for write-cache. Opens in read-only mode if ro is true. func OpenDB(p string, ro bool) (*bbolt.DB, error) { - return bbolt.Open(path.Join(p, dbName), os.ModePerm, &bbolt.Options{ + return bbolt.Open(filepath.Join(p, dbName), os.ModePerm, &bbolt.Options{ NoFreelistSync: true, NoSync: true, ReadOnly: ro, diff --git a/pkg/util/locode/db/boltdb/calls.go b/pkg/util/locode/db/boltdb/calls.go index b121d86194..79670cab15 100644 --- a/pkg/util/locode/db/boltdb/calls.go +++ b/pkg/util/locode/db/boltdb/calls.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "path" + "path/filepath" "github.com/nspcc-dev/neofs-node/pkg/util" locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db" @@ -20,7 +20,7 @@ func (db *DB) Open() error { // copy-paste from metabase: // consider universal Open/Close for BoltDB wrappers - err := util.MkdirAllX(path.Dir(db.path), db.mode) + err := util.MkdirAllX(filepath.Dir(db.path), db.mode) if err != nil { return fmt.Errorf("could not create dir for BoltDB: %w", err) } diff --git a/pkg/util/state/storage_test.go b/pkg/util/state/storage_test.go index 528b579845..0e00aed30b 100644 --- a/pkg/util/state/storage_test.go +++ b/pkg/util/state/storage_test.go @@ -1,7 +1,7 @@ package state_test import ( - "path" + "path/filepath" "testing" "github.com/nspcc-dev/neofs-node/pkg/util/state" @@ -9,7 +9,7 @@ import ( ) func TestPersistentStorage_UInt32(t *testing.T) { - storage, err := state.NewPersistentStorage(path.Join(t.TempDir(), ".storage")) + storage, err := state.NewPersistentStorage(filepath.Join(t.TempDir(), ".storage")) require.NoError(t, err) defer storage.Close()