[#727] Use `util.MkdirAllX` instead of `os.MkdirAll`

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
support/v0.27
Pavel Karpy 2021-07-28 19:19:33 +03:00 committed by Alex Vanin
parent 51eeae3640
commit 7a10d902be
6 changed files with 21 additions and 20 deletions

View File

@ -3,13 +3,12 @@ package main
import (
"context"
"net"
"os"
"path"
"sync"
"time"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
neogoutil "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-api-go/pkg"
apiclient "github.com/nspcc-dev/neofs-api-go/pkg/client"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
@ -44,7 +43,7 @@ import (
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
"github.com/nspcc-dev/neofs-node/pkg/services/util/response"
util2 "github.com/nspcc-dev/neofs-node/pkg/util"
util "github.com/nspcc-dev/neofs-node/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2"
"go.etcd.io/bbolt"
@ -133,25 +132,25 @@ type cfgMorph struct {
}
type cfgAccounting struct {
scriptHash util.Uint160
scriptHash neogoutil.Uint160
}
type cfgContainer struct {
scriptHash util.Uint160
scriptHash neogoutil.Uint160
parsers map[event.Type]event.Parser
subscribers map[event.Type][]event.Handler
workerPool util2.WorkerPool // pool for asynchronous handlers
workerPool util.WorkerPool // pool for asynchronous handlers
}
type cfgNetmap struct {
scriptHash util.Uint160
scriptHash neogoutil.Uint160
wrapper *nmwrapper.Wrapper
parsers map[event.Type]event.Parser
subscribers map[event.Type][]event.Handler
workerPool util2.WorkerPool // pool for asynchronous handlers
workerPool util.WorkerPool // pool for asynchronous handlers
state *networkState
@ -192,13 +191,13 @@ type cfgControlService struct {
}
type cfgReputation struct {
workerPool util2.WorkerPool // pool for EigenTrust algorithm's iterations
workerPool util.WorkerPool // pool for EigenTrust algorithm's iterations
localTrustStorage *truststorage.Storage
localTrustCtrl *trustcontroller.Controller
scriptHash util.Uint160
scriptHash neogoutil.Uint160
}
func initCfg(path string) *cfg {
@ -359,7 +358,7 @@ func initShardOptions(c *cfg) {
metaPath := metabaseCfg.Path()
metaPerm := metabaseCfg.Perm()
fatalOnErr(os.MkdirAll(path.Dir(metaPath), metaPerm))
fatalOnErr(util.MkdirAllX(path.Dir(metaPath), metaPerm))
opts = append(opts, []shard.Option{
shard.WithLogger(c.log),
@ -387,7 +386,7 @@ func initShardOptions(c *cfg) {
shard.WithWriteCacheOptions(writeCacheOpts...),
shard.WithRemoverBatchSize(gcCfg.RemoverBatchSize()),
shard.WithGCRemoverSleepInterval(gcCfg.RemoverSleepInterval()),
shard.WithGCWorkerPoolInitializer(func(sz int) util2.WorkerPool {
shard.WithGCWorkerPoolInitializer(func(sz int) util.WorkerPool {
pool, err := ants.NewPool(sz)
fatalOnErr(err)

View File

@ -3,9 +3,9 @@ package blobovnicza
import (
"errors"
"fmt"
"os"
"path"
"github.com/nspcc-dev/neofs-node/pkg/util"
"go.etcd.io/bbolt"
"go.uber.org/zap"
)
@ -18,7 +18,7 @@ func (b *Blobovnicza) Open() error {
zap.String("path", b.path),
)
err := os.MkdirAll(path.Dir(b.path), b.perm)
err := util.MkdirAllX(path.Dir(b.path), b.perm)
if err == nil {
b.log.Debug("opening BoltDB",
zap.String("path", b.path),

View File

@ -10,6 +10,7 @@ import (
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/util"
)
// FSTree represents object storage as filesystem tree.
@ -157,7 +158,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 := os.MkdirAll(path.Dir(p), t.Permissions); err != nil {
if err := util.MkdirAllX(path.Dir(p), t.Permissions); err != nil {
return err
}

View File

@ -2,16 +2,16 @@ package meta
import (
"fmt"
"os"
"path"
"github.com/nspcc-dev/neofs-node/pkg/util"
"go.etcd.io/bbolt"
"go.uber.org/zap"
)
// Open boltDB instance for metabase.
func (db *DB) Open() error {
err := os.MkdirAll(path.Dir(db.info.Path), db.info.Permission)
err := util.MkdirAllX(path.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)
}

View File

@ -10,6 +10,7 @@ import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
"github.com/nspcc-dev/neofs-node/pkg/util"
"go.etcd.io/bbolt"
"go.uber.org/zap"
)
@ -26,7 +27,7 @@ const lruKeysCount = 256 * 1024 * 8
const dbName = "small.bolt"
func (c *cache) openStore() error {
if err := os.MkdirAll(c.path, os.ModePerm); err != nil {
if err := util.MkdirAllX(c.path, os.ModePerm); err != nil {
return err
}

View File

@ -4,9 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"path"
"github.com/nspcc-dev/neofs-node/pkg/util"
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
"go.etcd.io/bbolt"
)
@ -20,7 +20,7 @@ func (db *DB) Open() error {
// copy-paste from metabase:
// consider universal Open/Close for BoltDB wrappers
err := os.MkdirAll(path.Dir(db.path), db.mode)
err := util.MkdirAllX(path.Dir(db.path), db.mode)
if err != nil {
return fmt.Errorf("could not create dir for BoltDB: %w", err)
}