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
14a384d8
Commit
14a384d8
authored
Oct 01, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pin: add depth arg.
parent
728f17d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
cmd/ipfs/pin.go
cmd/ipfs/pin.go
+2
-1
core/commands/pin.go
core/commands/pin.go
+12
-4
No files found.
cmd/ipfs/pin.go
View file @
14a384d8
...
...
@@ -20,6 +20,7 @@ var cmdIpfsPin = &commander.Command{
func
init
()
{
cmdIpfsPin
.
Flag
.
Bool
(
"r"
,
false
,
"pin objects recursively"
)
cmdIpfsPin
.
Flag
.
Int
(
"d"
,
1
,
"recursive depth"
)
}
var
pinCmd
=
MakeCommand
(
"pin"
,
[]
string
{
"r"
},
commands
.
Pin
)
var
pinCmd
=
MakeCommand
(
"pin"
,
[]
string
{
"r"
,
"d"
},
commands
.
Pin
)
core/commands/pin.go
View file @
14a384d8
...
...
@@ -9,12 +9,20 @@ import (
func
Pin
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
// if recursive, set flag
depth
:=
1
if
r
,
ok
:=
opts
[
"r"
]
.
(
bool
);
r
&&
ok
{
depth
=
-
1
// set recursive flag
recursive
,
_
:=
opts
[
"r"
]
.
(
bool
)
// false if cast fails.
// if recursive, set depth flag
depth
:=
1
// default (non recursive)
if
d
,
ok
:=
opts
[
"d"
]
.
(
int
);
recursive
&&
ok
{
depth
=
d
}
if
depth
<
-
1
{
return
fmt
.
Errorf
(
"ipfs pin: called with invalid depth: %v"
,
depth
)
}
fmt
.
Printf
(
"recursive, depth: %v, %v
\n
"
,
recursive
,
depth
)
for
_
,
fn
:=
range
args
{
dagnode
,
err
:=
n
.
Resolver
.
ResolvePath
(
fn
)
if
err
!=
nil
{
...
...
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