diff --git a/cmd/ipfs/util/ulimit_test.go b/cmd/ipfs/util/ulimit_test.go index 0b6a227a5..2fe42198b 100644 --- a/cmd/ipfs/util/ulimit_test.go +++ b/cmd/ipfs/util/ulimit_test.go @@ -42,7 +42,7 @@ func TestManageInvalidNFds(t *testing.T) { if changed, new, err := ManageFdLimit(); err == nil { t.Errorf("ManageFdLimit should return an error: changed %t, new: %d", changed, new) - } else if err != nil { + } else { flag := strings.Contains(err.Error(), "failed to raise ulimit to IPFS_FD_MAX") if !flag { diff --git a/core/builder.go b/core/builder.go index 60cf2cb23..6f796ddf5 100644 --- a/core/builder.go +++ b/core/builder.go @@ -31,7 +31,10 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) { // Note that some services use contexts to signal shutting down, which is // very suboptimal. This needs to be here until that's addressed somehow <-ctx.Done() - app.Stop(context.Background()) + err := app.Stop(context.Background()) + if err != nil { + log.Error("failure on stop: ", err) + } }() n.IsOnline = cfg.Online diff --git a/core/commands/block.go b/core/commands/block.go index 46d18ff8e..69b2c77d3 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -224,6 +224,9 @@ It takes a list of base58 encoded multihashes to remove. // TODO: use batching coreapi when done for _, b := range req.Arguments { rp, err := api.ResolvePath(req.Context, path.New(b)) + if err != nil { + return err + } err = api.Block().Rm(req.Context, rp, options.Block.Force(force)) if err != nil { diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index 5ddfb9d80..a198ea11b 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -61,10 +61,8 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { c.SetAllowedMethods(acam...) } - if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil { - for _, v := range acac { - c.SetAllowCredentials(strings.ToLower(v) == "true") - } + for _, v := range nc.API.HTTPHeaders[cmdsHttp.ACACredentials] { + c.SetAllowCredentials(strings.ToLower(v) == "true") } c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1) diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index f2fb0f46d..43d601db8 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -68,7 +68,7 @@ func TestAddMultipleGCLive(t *testing.T) { go func() { defer close(out) - adder.AddAllAndPin(slf) + _, _ = adder.AddAllAndPin(slf) // Ignore errors for clarity - the real bug would be gc'ing files while adding them, not this resultant error }() diff --git a/core/node/builder.go b/core/node/builder.go index 5228310f2..8424acbcd 100644 --- a/core/node/builder.go +++ b/core/node/builder.go @@ -15,13 +15,10 @@ import ( ds "github.com/ipfs/go-datastore" dsync "github.com/ipfs/go-datastore/sync" cfg "github.com/ipfs/go-ipfs-config" - logging "github.com/ipfs/go-log" ci "github.com/libp2p/go-libp2p-crypto" peer "github.com/libp2p/go-libp2p-peer" ) -var log = logging.Logger("node") - type BuildCfg struct { // If online is set, the node will have networking enabled Online bool diff --git a/core/node/storage.go b/core/node/storage.go index 5d705359b..01cc6e062 100644 --- a/core/node/storage.go +++ b/core/node/storage.go @@ -91,7 +91,7 @@ func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockst // GcBlockstoreCtor wraps GcBlockstore and adds Filestore support func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore, fstore *filestore.Filestore) { - gclocker, gcbs, bs = GcBlockstoreCtor(bb) + gclocker = blockstore.NewGCLocker() // hash security fstore = filestore.NewFilestore(bb, repo.FileManager()) diff --git a/filestore/fsrefstore.go b/filestore/fsrefstore.go index b4c66a32d..320ee5928 100644 --- a/filestore/fsrefstore.go +++ b/filestore/fsrefstore.go @@ -281,7 +281,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error { if !f.AllowFiles { return ErrFilestoreNotEnabled } - if !filepath.HasPrefix(b.PosInfo.FullPath, f.root) { + if !filepath.HasPrefix(b.PosInfo.FullPath, f.root) { //nolint:staticcheck return fmt.Errorf("cannot add filestore references outside ipfs root (%s)", f.root) }