diff --git a/core/commands/files.go b/core/commands/files.go index e48abba2815..bba14a1e10f 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -1245,7 +1245,10 @@ func getFileHandle(r *mfs.Root, path string, create bool, builder cid.Builder) ( } nd := dag.NodeWithData(ft.FilePBData(nil, 0)) - nd.SetCidBuilder(builder) + err = nd.SetCidBuilder(builder) + if err != nil { + return nil, err + } err = pdir.AddChild(fname, nd) if err != nil { return nil, err diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 332d28f560d..44864d04664 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -537,7 +537,9 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) Cid: c, } } - dagnode.SetLinks(links) + if err := dagnode.SetLinks(links); err != nil { + return nil, err + } return dagnode, nil } diff --git a/core/coreapi/object.go b/core/coreapi/object.go index d2bd08addec..28dd0df08f6 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -405,7 +405,9 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) Cid: c, } } - dagnode.SetLinks(links) + if err := dagnode.SetLinks(links); err != nil { + return nil, err + } return dagnode, nil } diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index e0fe0eb137d..817556e04a8 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -177,7 +177,10 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options md := dagtest.Mock() emptyDirNode := ft.EmptyDirNode() // Use the same prefix for the "empty" MFS root as for the file adder. - emptyDirNode.SetCidBuilder(fileAdder.CidBuilder) + err := emptyDirNode.SetCidBuilder(fileAdder.CidBuilder) + if err != nil { + return nil, err + } mr, err := mfs.NewRoot(ctx, md, emptyDirNode, nil) if err != nil { return nil, err diff --git a/core/coredag/dagpb.go b/core/coredag/dagpb.go index d1c7bcf0963..658bda49f08 100644 --- a/core/coredag/dagpb.go +++ b/core/coredag/dagpb.go @@ -24,7 +24,10 @@ func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) return nil, err } - nd.SetCidBuilder(cidPrefix(mhType, mhLen)) + err = nd.SetCidBuilder(cidPrefix(mhType, mhLen)) + if err != nil { + return nil, err + } return []ipld.Node{nd}, nil } @@ -40,7 +43,10 @@ func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) return nil, err } - nd.SetCidBuilder(cidPrefix(mhType, mhLen)) + err = nd.SetCidBuilder(cidPrefix(mhType, mhLen)) + if err != nil { + return nil, err + } return []ipld.Node{nd}, nil } diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 54e5873a9d4..16ccbaefac7 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -87,7 +87,10 @@ func (adder *Adder) mfsRoot() (*mfs.Root, error) { return adder.mroot, nil } rnode := unixfs.EmptyDirNode() - rnode.SetCidBuilder(adder.CidBuilder) + err := rnode.SetCidBuilder(adder.CidBuilder) + if err != nil { + return nil, err + } mr, err := mfs.NewRoot(adder.ctx, adder.dagService, rnode, nil) if err != nil { return nil, err @@ -384,7 +387,10 @@ func (adder *Adder) addSymlink(path string, l *files.Symlink) error { } dagnode := dag.NodeWithData(sdata) - dagnode.SetCidBuilder(adder.CidBuilder) + err = dagnode.SetCidBuilder(adder.CidBuilder) + if err != nil { + return err + } err = adder.dagService.Add(adder.ctx, dagnode) if err != nil { return err