chore: fix linter nits

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen 2019-05-10 23:53:44 -07:00
parent 96e6dd294f
commit 4924b80e10
8 changed files with 13 additions and 12 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -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
}()

View File

@ -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

View File

@ -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())

View File

@ -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)
}