提交 4c348701 作者: Jeromy Johnson 提交者: GitHub

Merge pull request #4072 from ipfs/fix/dag-put-order

fix determination of 'root' node in dag put
...@@ -79,25 +79,28 @@ into an object of the specified format. ...@@ -79,25 +79,28 @@ into an object of the specified format.
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
if len(nds) == 0 {
res.SetError(fmt.Errorf("no node returned from ParseInputs"), cmds.ErrNormal)
return
}
var c *cid.Cid
b := n.DAG.Batch() b := n.DAG.Batch()
for _, nd := range nds { for _, nd := range nds {
cid, err := b.Add(nd) _, err := b.Add(nd)
if err != nil { if err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
c = cid
} }
if err := b.Commit(); err != nil { if err := b.Commit(); err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
root := nds[0].Cid()
if dopin { if dopin {
n.Pinning.PinWithMode(c, pin.Recursive) n.Pinning.PinWithMode(root, pin.Recursive)
err := n.Pinning.Flush() err := n.Pinning.Flush()
if err != nil { if err != nil {
...@@ -106,7 +109,7 @@ into an object of the specified format. ...@@ -106,7 +109,7 @@ into an object of the specified format.
} }
} }
res.SetOutput(&OutputObject{Cid: c}) res.SetOutput(&OutputObject{Cid: root})
}, },
Type: OutputObject{}, Type: OutputObject{},
Marshalers: cmds.MarshalerMap{ Marshalers: cmds.MarshalerMap{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论