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
652e3d05
Commit
652e3d05
authored
10 years ago
by
Matt Bell
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands2: Fixed 'add' output adding an empty object
parent
20285ead
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
core/commands2/add.go
core/commands2/add.go
+7
-7
No files found.
core/commands2/add.go
View file @
652e3d05
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
var
ErrDepthLimitExceeded
=
fmt
.
Errorf
(
"depth limit exceeded"
)
var
ErrDepthLimitExceeded
=
fmt
.
Errorf
(
"depth limit exceeded"
)
type
AddOutput
struct
{
type
AddOutput
struct
{
Added
[]
Object
Added
[]
*
Object
}
}
var
addCmd
=
&
cmds
.
Command
{
var
addCmd
=
&
cmds
.
Command
{
...
@@ -24,7 +24,7 @@ var addCmd = &cmds.Command{
...
@@ -24,7 +24,7 @@ var addCmd = &cmds.Command{
cmds
.
Option
{[]
string
{
"recursive"
,
"r"
},
cmds
.
Bool
,
"Must be specified when adding directories"
},
cmds
.
Option
{[]
string
{
"recursive"
,
"r"
},
cmds
.
Bool
,
"Must be specified when adding directories"
},
},
},
Arguments
:
[]
cmds
.
Argument
{
Arguments
:
[]
cmds
.
Argument
{
cmds
.
Argument
{
"file"
,
cmds
.
ArgFile
,
fals
e
,
true
,
"The path to a file to be added to IPFS"
},
cmds
.
Argument
{
"file"
,
cmds
.
ArgFile
,
tru
e
,
true
,
"The path to a file to be added to IPFS"
},
},
},
Description
:
"Add an object to ipfs."
,
Description
:
"Add an object to ipfs."
,
Help
:
`Adds contents of <path> to ipfs. Use -r to add directories.
Help
:
`Adds contents of <path> to ipfs. Use -r to add directories.
...
@@ -52,15 +52,15 @@ var addCmd = &cmds.Command{
...
@@ -52,15 +52,15 @@ var addCmd = &cmds.Command{
return
return
}
}
added
:=
make
([]
Object
,
len
(
req
.
Arguments
()))
added
:=
make
([]
*
Object
,
0
,
len
(
req
.
Arguments
()))
for
_
,
dagnode
:=
range
dagnodes
{
for
_
,
dagnode
:=
range
dagnodes
{
object
,
err
:=
getOutput
(
dagnode
)
k
,
err
:=
dagnode
.
Key
()
if
err
!=
nil
{
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
return
}
}
added
=
append
(
added
,
Object
{
Hash
:
k
.
String
(),
Links
:
nil
})
added
=
append
(
added
,
object
)
}
}
res
.
SetOutput
(
&
AddOutput
{
added
})
res
.
SetOutput
(
&
AddOutput
{
added
})
...
@@ -88,7 +88,6 @@ var addCmd = &cmds.Command{
...
@@ -88,7 +88,6 @@ var addCmd = &cmds.Command{
}
}
func
add
(
n
*
core
.
IpfsNode
,
readers
[]
io
.
Reader
)
([]
*
dag
.
Node
,
error
)
{
func
add
(
n
*
core
.
IpfsNode
,
readers
[]
io
.
Reader
)
([]
*
dag
.
Node
,
error
)
{
dagnodes
:=
make
([]
*
dag
.
Node
,
0
)
dagnodes
:=
make
([]
*
dag
.
Node
,
0
)
for
_
,
reader
:=
range
readers
{
for
_
,
reader
:=
range
readers
{
...
@@ -104,6 +103,7 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
...
@@ -104,6 +103,7 @@ func add(n *core.IpfsNode, readers []io.Reader) ([]*dag.Node, error) {
dagnodes
=
append
(
dagnodes
,
node
)
dagnodes
=
append
(
dagnodes
,
node
)
}
}
return
dagnodes
,
nil
return
dagnodes
,
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