Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
1b51d9db
提交
1b51d9db
authored
4月 28, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1138 from vitorbaptista/1134-display-types-on-pin-ls
core/commands: pin ls: display types by default
上级
4c133697
5d1a25bb
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
44 行增加
和
14 行删除
+44
-14
pin.go
core/commands/pin.go
+36
-8
t0080-repo.sh
test/sharness/t0080-repo.sh
+8
-6
没有找到文件。
core/commands/pin.go
浏览文件 @
1b51d9db
...
...
@@ -173,6 +173,7 @@ Defaults to "direct".
Options
:
[]
cmds
.
Option
{
cmds
.
StringOption
(
"type"
,
"t"
,
"The type of pinned keys to list. Can be
\"
direct
\"
,
\"
indirect
\"
,
\"
recursive
\"
, or
\"
all
\"
. Defaults to
\"
direct
\"
"
),
cmds
.
BoolOption
(
"count"
,
"n"
,
"Show refcount when listing indirect pins"
),
cmds
.
BoolOption
(
"quiet"
,
"q"
,
"Write just hashes of objects"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
req
.
Context
()
.
GetNode
()
...
...
@@ -197,20 +198,29 @@ Defaults to "direct".
res
.
SetError
(
err
,
cmds
.
ErrClient
)
}
keys
:=
make
(
map
[
string
]
in
t
)
keys
:=
make
(
map
[
string
]
RefKeyObjec
t
)
if
typeStr
==
"direct"
||
typeStr
==
"all"
{
for
_
,
k
:=
range
n
.
Pinning
.
DirectKeys
()
{
keys
[
k
.
B58String
()]
=
1
keys
[
k
.
B58String
()]
=
RefKeyObject
{
Type
:
"direct"
,
Count
:
1
,
}
}
}
if
typeStr
==
"indirect"
||
typeStr
==
"all"
{
for
k
,
v
:=
range
n
.
Pinning
.
IndirectKeys
()
{
keys
[
k
.
B58String
()]
=
v
keys
[
k
.
B58String
()]
=
RefKeyObject
{
Type
:
"indirect"
,
Count
:
v
,
}
}
}
if
typeStr
==
"recursive"
||
typeStr
==
"all"
{
for
_
,
k
:=
range
n
.
Pinning
.
RecursiveKeys
()
{
keys
[
k
.
B58String
()]
=
1
keys
[
k
.
B58String
()]
=
RefKeyObject
{
Type
:
"recursive"
,
Count
:
1
,
}
}
}
...
...
@@ -229,6 +239,11 @@ Defaults to "direct".
return
nil
,
err
}
quiet
,
_
,
err
:=
res
.
Request
()
.
Option
(
"quiet"
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
keys
,
ok
:=
res
.
Output
()
.
(
*
RefKeyList
)
if
!
ok
{
return
nil
,
u
.
ErrCast
()
...
...
@@ -236,11 +251,19 @@ Defaults to "direct".
out
:=
new
(
bytes
.
Buffer
)
if
typeStr
==
"indirect"
&&
count
{
for
k
,
v
:=
range
keys
.
Keys
{
fmt
.
Fprintf
(
out
,
"%s %d
\n
"
,
k
,
v
)
if
quiet
{
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
k
,
v
.
Count
)
}
else
{
fmt
.
Fprintf
(
out
,
"%s %s %d
\n
"
,
k
,
v
.
Type
,
v
.
Count
)
}
}
}
else
{
for
k
,
_
:=
range
keys
.
Keys
{
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
k
)
for
k
,
v
:=
range
keys
.
Keys
{
if
quiet
{
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
k
)
}
else
{
fmt
.
Fprintf
(
out
,
"%s %s
\n
"
,
k
,
v
.
Type
)
}
}
}
return
out
,
nil
...
...
@@ -248,6 +271,11 @@ Defaults to "direct".
},
}
type
RefKeyObject
struct
{
Type
string
Count
int
}
type
RefKeyList
struct
{
Keys
map
[
string
]
in
t
Keys
map
[
string
]
RefKeyObjec
t
}
test/sharness/t0080-repo.sh
浏览文件 @
1b51d9db
...
...
@@ -49,7 +49,7 @@ test_expect_success "file no longer pinned" '
echo "$HASH_WELCOME_DOCS" >expected2 &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>expected2 &&
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >> expected2 &&
ipfs pin ls --type=recursive >actual2 &&
ipfs pin ls --type=recursive
--quiet
>actual2 &&
test_sort_cmp expected2 actual2
'
...
...
@@ -105,6 +105,7 @@ test_expect_success "adding multiblock random file succeeds" '
test_expect_success
"'ipfs pin ls --type=indirect' is correct"
'
ipfs refs "$MBLOCKHASH" >refsout &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>refsout &&
sed -i="" "s/\(.*\)/\1 indirect/g" refsout &&
ipfs pin ls --type=indirect >indirectpins &&
test_sort_cmp refsout indirectpins
'
...
...
@@ -122,7 +123,7 @@ test_expect_success "pin something directly" '
'
test_expect_success
"'ipfs pin ls --type=direct' is correct"
'
echo "$DIRECTPIN" >directpinexpected &&
echo "$DIRECTPIN
direct
" >directpinexpected &&
ipfs pin ls --type=direct >directpinout &&
test_sort_cmp directpinexpected directpinout
'
...
...
@@ -132,17 +133,18 @@ test_expect_success "'ipfs pin ls --type=recursive' is correct" '
echo "$HASH_WELCOME_DOCS" >>rp_expected &&
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >>rp_expected &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>rp_expected &&
sed -i="" "s/\(.*\)/\1 recursive/g" rp_expected &&
ipfs pin ls --type=recursive >rp_actual &&
test_sort_cmp rp_expected rp_actual
'
test_expect_success
"'ipfs pin ls --type=all' is correct"
'
test_expect_success
"'ipfs pin ls --type=all
--quiet
' is correct"
'
cat directpinout >allpins &&
cat rp_actual >>allpins &&
cat indirectpins >>allpins &&
c
at allpins | sort | uniq >> allpins_uniq
&&
ipfs pin ls --type=all >actual_allpins &&
test_sort_cmp allpins_uniq actual_allpins
c
ut -f1 -d " " allpins | sort | uniq >> allpins_uniq_hashes
&&
ipfs pin ls --type=all
--quiet
>actual_allpins &&
test_sort_cmp allpins_uniq
_hashes
actual_allpins
'
test_kill_ipfs_daemon
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论