Commit 652e3d05 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

core/commands2: Fixed 'add' output adding an empty object

parent 20285ead
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded") var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")
type AddOutput struct { type AddOutput struct {
Added []Object Added []*Object
} }
var addCmd = &cmds.Command{ var addCmd = &cmds.Command{
...@@ -24,7 +24,7 @@ var addCmd = &cmds.Command{ ...@@ -24,7 +24,7 @@ var addCmd = &cmds.Command{
cmds.Option{[]string{"recursive", "r"}, cmds.Bool, "Must be specified when adding directories"}, cmds.Option{[]string{"recursive", "r"}, cmds.Bool, "Must be specified when adding directories"},
}, },
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"file", cmds.ArgFile, false, true, "The path to a file to be added to IPFS"}, cmds.Argument{"file", cmds.ArgFile, true, true, "The path to a file to be added to IPFS"},
}, },
Description: "Add an object to ipfs.", Description: "Add an object to ipfs.",
Help: `Adds contents of <path> to ipfs. Use -r to add directories. Help: `Adds contents of <path> to ipfs. Use -r to add directories.
...@@ -52,15 +52,15 @@ var addCmd = &cmds.Command{ ...@@ -52,15 +52,15 @@ var addCmd = &cmds.Command{
return return
} }
added := make([]Object, len(req.Arguments())) added := make([]*Object, 0, len(req.Arguments()))
for _, dagnode := range dagnodes { for _, dagnode := range dagnodes {
object, err := getOutput(dagnode)
k, err := dagnode.Key()
if err != nil { if err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
added = append(added, Object{Hash: k.String(), Links: nil})
added = append(added, object)
} }
res.SetOutput(&AddOutput{added}) res.SetOutput(&AddOutput{added})
...@@ -88,7 +88,6 @@ var addCmd = &cmds.Command{ ...@@ -88,7 +88,6 @@ var addCmd = &cmds.Command{
} }
func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) { func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
dagnodes := make([]*dag.Node, 0) dagnodes := make([]*dag.Node, 0)
for _, reader := range readers { for _, reader := range readers {
...@@ -104,6 +103,7 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) { ...@@ -104,6 +103,7 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
dagnodes = append(dagnodes, node) dagnodes = append(dagnodes, node)
} }
return dagnodes, nil return dagnodes, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment