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
353cb399
Commit
353cb399
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
refac(commands2/ls) split loop
@mappum
parent
6d89094d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
core/commands2/ls.go
core/commands2/ls.go
+19
-4
No files found.
core/commands2/ls.go
View file @
353cb399
package
commands
import
(
"errors"
"fmt"
cmds
"github.com/jbenet/go-ipfs/commands"
merkledag
"github.com/jbenet/go-ipfs/merkledag"
)
type
Link
struct
{
...
...
@@ -27,18 +29,31 @@ var lsCmd = &cmds.Command{
Help
:
"TODO"
,
Run
:
func
(
res
cmds
.
Response
,
req
cmds
.
Request
)
{
node
:=
req
.
Context
()
.
Node
output
:=
make
([]
Object
,
len
(
req
.
Arguments
()))
for
i
,
arg
:=
range
req
.
Arguments
()
{
path
:=
arg
.
(
string
)
paths
:=
make
([]
string
,
0
)
for
_
,
arg
:=
range
req
.
Arguments
()
{
path
,
ok
:=
arg
.
(
string
)
if
!
ok
{
res
.
SetError
(
errors
.
New
(
"cast error"
),
cmds
.
ErrNormal
)
return
}
paths
=
append
(
paths
,
path
)
}
dagnodes
:=
make
([]
*
merkledag
.
Node
,
0
)
for
_
,
path
:=
range
paths
{
dagnode
,
err
:=
node
.
Resolver
.
ResolvePath
(
path
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
dagnodes
=
append
(
dagnodes
,
dagnode
)
}
output
:=
make
([]
Object
,
len
(
req
.
Arguments
()))
for
i
,
dagnode
:=
range
dagnodes
{
output
[
i
]
=
Object
{
Hash
:
path
,
Hash
:
path
s
[
i
]
,
Links
:
make
([]
Link
,
len
(
dagnode
.
Links
)),
}
for
j
,
link
:=
range
dagnode
.
Links
{
...
...
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