Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
537f94a3
Commit
537f94a3
authored
Nov 13, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object get: Fixed protobuf marshaling
parent
4eaf38c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
7 deletions
+26
-7
core/commands2/object.go
core/commands2/object.go
+26
-7
No files found.
core/commands2/object.go
View file @
537f94a3
...
...
@@ -7,6 +7,8 @@ import (
"io"
"io/ioutil"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
dag
"github.com/jbenet/go-ipfs/merkledag"
...
...
@@ -108,23 +110,23 @@ var objectGetCmd = &cmds.Command{
Tagline
:
"Get and serialize the DAG node named by <key>"
,
ShortDescription
:
`
'ipfs object get' is a plumbing command for retreiving DAG nodes.
It serializes the DAG node to the format specified by the "--encoding"
flag.
It outputs to stdout, and <key> is a base58 encoded multihash.
It serializes the DAG node to the format specified by the "--encoding"
flag.
It outputs to stdout, and <key> is a base58 encoded multihash.
`
,
LongDescription
:
`
'ipfs object get' is a plumbing command for retreiving DAG nodes.
It serializes the DAG node to the format specified by the "--encoding"
flag.
It outputs to stdout, and <key> is a base58 encoded multihash.
It serializes the DAG node to the format specified by the "--encoding"
flag.
It outputs to stdout, and <key> is a base58 encoded multihash.
This command outputs data in the following encodings:
* "protobuf"
* "json"
* "xml"
(Specified by the "--encoding" or "-enc" flag
s
)`
,
(Specified by the "--encoding" or "-enc" flag)`
,
},
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"key"
,
true
,
false
,
"Key of the object to retrieve
\n
(in base58-encoded multihash format)"
),
cmds
.
StringArg
(
"key"
,
true
,
false
,
"Key of the object to retrieve
(in base58-encoded multihash format)"
),
},
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
n
,
err
:=
req
.
Context
()
.
GetNode
()
...
...
@@ -160,7 +162,24 @@ This command outputs data in the following encodings:
Type
:
&
Node
{},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
EncodingType
(
"protobuf"
)
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
object
:=
res
.
Output
()
.
(
*
dag
.
Node
)
node
:=
res
.
Output
()
.
(
*
Node
)
// convert the Node object into a real dag.Node
object
:=
new
(
dag
.
Node
)
object
.
Data
=
node
.
Data
object
.
Links
=
make
([]
*
dag
.
Link
,
len
(
node
.
Links
))
for
i
,
link
:=
range
node
.
Links
{
hash
,
err
:=
mh
.
FromB58String
(
link
.
Hash
)
if
err
!=
nil
{
return
nil
,
err
}
object
.
Links
[
i
]
=
&
dag
.
Link
{
Name
:
link
.
Name
,
Size
:
link
.
Size
,
Hash
:
hash
,
}
}
return
object
.
Marshal
()
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment