@cryptotaxi247 / kubo / commits / 1e1d70b28

fix panic in offline calls of 'ipfs object stat'

Jeromy committed Feb 19, 2015 at 07:40 UTC 1e1d70b28ab935d8ad1d62fb0c90a07a44dd439c
2 files changed +5 -5
merkledag/merkledag_test.go
+1 -1
@@ -122,7 +122,7 @@ func SubtestNodeStat(t *testing.T, n *Node) {
122 return
123 }
124
125 - if expected != actual {
125 + if expected != *actual {
126 t.Error("n.Stat incorrect.\nexpect: %s\nactual: %s", expected, actual)
127 } else {
128 fmt.Printf("n.Stat correct: %s\n", actual)
merkledag/node.go
+4 -4
@@ -160,18 +160,18 @@ func (n *Node) Size() (uint64, error) {
160 }
161
162 // Stat returns statistics on the node.
163 -func (n *Node) Stat() (NodeStat, error) {
163 +func (n *Node) Stat() (*NodeStat, error) {
164 enc, err := n.Encoded(false)
165 if err != nil {
166 - return NodeStat{}, err
166 + return nil, err
167 }
168
169 cumSize, err := n.Size()
170 if err != nil {
171 - return NodeStat{}, err
171 + return nil, err
172 }
173
174 - return NodeStat{
174 + return &NodeStat{
175 NumLinks: len(n.Links),
176 BlockSize: len(enc),
177 LinksSize: len(enc) - len(n.Data), // includes framing.