Skip to content

Commit

Permalink
fix: correctly handle errors in balancedbuilder's Layout
Browse files Browse the repository at this point in the history
this will lose block when newRoot.AddChild returns err.
in ipfs-cluster single dag service add(context.TODO(), node) maybe failed when not enough peers to allocate for this block node


This commit was moved from ipfs/go-unixfs@98e2622
  • Loading branch information
cpucorecore authored and Jorropo committed Feb 10, 2023
1 parent 6c761b3 commit 6e23bc2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion unixfs/importer/balanced/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {

// Add the old `root` as a child of the `newRoot`.
newRoot := db.NewFSNodeOverDag(ft.TFile)
newRoot.AddChild(root, fileSize, db)
err = newRoot.AddChild(root, fileSize, db)
if err != nil {
return nil, err
}

// Fill the `newRoot` (that has the old `root` already as child)
// and make it the current `root` for the next iteration (when
Expand Down

0 comments on commit 6e23bc2

Please sign in to comment.