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
4c029a86
Commit
4c029a86
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
extract toStrings method
parent
86f0aac8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
core/commands2/pin.go
core/commands2/pin.go
+17
-9
No files found.
core/commands2/pin.go
View file @
4c029a86
...
...
@@ -37,17 +37,13 @@ var pinCmd = &cmds.Command{
}
}*/
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
)
paths
,
err
:=
toStrings
(
req
.
Arguments
())
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
_
,
err
:
=
pin
(
n
,
paths
,
recursive
)
_
,
err
=
pin
(
n
,
paths
,
recursive
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
}
...
...
@@ -126,3 +122,15 @@ func pin(n *core.IpfsNode, paths []string, recursive bool) ([]*merkledag.Node, e
return
dagnodes
,
nil
}
func
toStrings
(
slice
[]
interface
{})
([]
string
,
error
)
{
strs
:=
make
([]
string
,
0
)
for
_
,
maybe
:=
range
slice
{
str
,
ok
:=
maybe
.
(
string
)
if
!
ok
{
return
nil
,
errors
.
New
(
"cast error"
)
}
strs
=
append
(
strs
,
str
)
}
return
strs
,
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