@cryptotaxi247 / kubo / commits / 652e3d052

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

Matt Bell committed Nov 8, 2014 at 20:31 UTC 652e3d0523e5de427877e7b33cf8844cfad0b9e8
1 file changed +7 -7
core/commands2/add.go
+7 -7
@@ -16,7 +16,7 @@ import (
16 var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")
17
18 type AddOutput struct {
19 - Added []Object
19 + Added []*Object
20 }
21
22 var addCmd = &cmds.Command{
@@ -24,7 +24,7 @@ var addCmd = &cmds.Command{
24 cmds.Option{[]string{"recursive", "r"}, cmds.Bool, "Must be specified when adding directories"},
25 },
26 Arguments: []cmds.Argument{
27 - cmds.Argument{"file", cmds.ArgFile, false, true, "The path to a file to be added to IPFS"},
27 + cmds.Argument{"file", cmds.ArgFile, true, true, "The path to a file to be added to IPFS"},
28 },
29 Description: "Add an object to ipfs.",
30 Help: `Adds contents of <path> to ipfs. Use -r to add directories.
@@ -52,15 +52,15 @@ var addCmd = &cmds.Command{
52 return
53 }
54
55 - added := make([]Object, len(req.Arguments()))
55 + added := make([]*Object, 0, len(req.Arguments()))
56 for _, dagnode := range dagnodes {
57 -
58 - k, err := dagnode.Key()
57 + object, err := getOutput(dagnode)
58 if err != nil {
59 res.SetError(err, cmds.ErrNormal)
60 return
61 }
63 - added = append(added, Object{Hash: k.String(), Links: nil})
62 +
63 + added = append(added, object)
64 }
65
66 res.SetOutput(&AddOutput{added})
@@ -88,7 +88,6 @@ var addCmd = &cmds.Command{
88 }
89
90 func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
91 -
91 dagnodes := make([]*dag.Node, 0)
92
93 for _, reader := range readers {
@@ -104,6 +103,7 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
103
104 dagnodes = append(dagnodes, node)
105 }
106 +
107 return dagnodes, nil
108 }
109