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-dms3
Commits
c65b01c5
Commit
c65b01c5
authored
10 years ago
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(add) cast safely
parent
084ffd97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
cmd/ipfs2/daemon.go
cmd/ipfs2/daemon.go
+1
-1
core/commands2/add.go
core/commands2/add.go
+9
-5
No files found.
cmd/ipfs2/daemon.go
View file @
c65b01c5
...
...
@@ -9,7 +9,7 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
cmdsHttp
"github.com/jbenet/go-ipfs/commands/http"
"github.com/jbenet/go-ipfs/core"
core
"github.com/jbenet/go-ipfs/core"
commands
"github.com/jbenet/go-ipfs/core/commands2"
daemon
"github.com/jbenet/go-ipfs/daemon2"
)
...
...
This diff is collapsed.
Click to expand it.
core/commands2/add.go
View file @
c65b01c5
...
...
@@ -62,14 +62,18 @@ var addCmd = &cmds.Command{
},
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
AddOutput
)
.
Added
if
len
(
v
)
==
1
{
s
:=
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
v
[
0
]
.
Hash
)
val
,
ok
:=
res
.
Output
()
.
(
*
AddOutput
)
if
!
ok
{
return
nil
,
errors
.
New
(
"cast err"
)
}
added
:=
val
.
Added
if
len
(
added
)
==
1
{
s
:=
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
added
[
0
]
.
Hash
)
return
[]
byte
(
s
),
nil
}
s
:=
fmt
.
Sprintf
(
"Added %v objects:
\n
"
,
len
(
v
))
for
_
,
obj
:=
range
v
{
s
:=
fmt
.
Sprintf
(
"Added %v objects:
\n
"
,
len
(
added
))
for
_
,
obj
:=
range
added
{
s
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
obj
.
Hash
)
}
return
[]
byte
(
s
),
nil
...
...
This diff is collapsed.
Click to expand it.
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