From f3733873de14682bb44186f9d2b4ddb2cd0befe1 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Sun, 9 Nov 2014 00:50:14 -0800 Subject: [PATCH] core/commands2: Fixed 'object get' dagnode output format --- core/commands2/object.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/commands2/object.go b/core/commands2/object.go index 22ce11322..bc08dcebe 100644 --- a/core/commands2/object.go +++ b/core/commands2/object.go @@ -17,6 +17,11 @@ var ErrObjectTooLarge = errors.New("input object was too large. limit is 512kbyt const inputLimit = 512 * 1024 +type Node struct { + Links []Link + Data []byte +} + var objectCmd = &cmds.Command{ Description: "Interact with ipfs objects", Help: `'ipfs object' is a plumbing command used to manipulate DAG objects directly.`, @@ -121,9 +126,22 @@ This command outputs data in the following encodings: return } - res.SetOutput(object) + node := &Node{ + Links: make([]Link, len(object.Links)), + Data: object.Data, + } + + for i, link := range object.Links { + node.Links[i] = Link{ + Hash: link.Hash.B58String(), + Name: link.Name, + Size: link.Size, + } + } + + res.SetOutput(node) }, - Type: &dag.Node{}, + Type: &Node{}, Marshallers: map[cmds.EncodingType]cmds.Marshaller{ cmds.EncodingType("protobuf"): func(res cmds.Response) ([]byte, error) { object := res.Output().(*dag.Node)