Skip to content

Commit

Permalink
fix: correctly handle return errors
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-unixfs@b7f6de0
  • Loading branch information
Jorropo committed Feb 10, 2023
1 parent 6e23bc2 commit 9f11814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions unixfs/importer/helpers/dagbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error {
return err
}
}
node.Commit()
// TODO: Do we need to commit here? The caller who created the
// `FSNodeOverDag` should be in charge of that.

return nil
_, err := node.Commit()
return err
}

// NewLeafDataNode builds the `node` with the data obtained from the
Expand Down
7 changes: 4 additions & 3 deletions unixfs/io/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ func NewDirectoryFromNode(dserv ipld.DAGService, node ipld.Node) (Directory, err

func (d *BasicDirectory) computeEstimatedSize() {
d.estimatedSize = 0
d.ForEachLink(context.TODO(), func(l *ipld.Link) error {
// err is just breaking the iteration and we always return nil
_ = d.ForEachLink(context.TODO(), func(l *ipld.Link) error {
d.addToEstimatedSize(l.Name, l.Cid)
return nil
})
Expand Down Expand Up @@ -570,7 +571,7 @@ func (d *DynamicDirectory) AddChild(ctx context.Context, name string, nd ipld.No
if err != nil {
return err
}
hamtDir.AddChild(ctx, name, nd)
err = hamtDir.AddChild(ctx, name, nd)
if err != nil {
return err
}
Expand Down Expand Up @@ -600,7 +601,7 @@ func (d *DynamicDirectory) RemoveChild(ctx context.Context, name string) error {
if err != nil {
return err
}
basicDir.RemoveChild(ctx, name)
err = basicDir.RemoveChild(ctx, name)
if err != nil {
return err
}
Expand Down

0 comments on commit 9f11814

Please sign in to comment.