Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
415aa2c6
提交
415aa2c6
authored
3月 18, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #942 from jbenet/fix/pin-init
fix for weird repo init issue
上级
e9ee1a36
3bf7d5c2
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
2 行删除
+43
-2
publisher.go
namesys/publisher.go
+3
-1
pin_test.go
pin/pin_test.go
+38
-0
t0080-repo.sh
test/sharness/t0080-repo.sh
+2
-1
没有找到文件。
namesys/publisher.go
浏览文件 @
415aa2c6
...
@@ -148,7 +148,9 @@ func InitializeKeyspace(ctx context.Context, ds dag.DAGService, pub Publisher, p
...
@@ -148,7 +148,9 @@ func InitializeKeyspace(ctx context.Context, ds dag.DAGService, pub Publisher, p
return
err
return
err
}
}
err
=
pins
.
Pin
(
emptyDir
,
false
)
// pin recursively because this might already be pinned
// and doing a direct pin would throw an error in that case
err
=
pins
.
Pin
(
emptyDir
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pin/pin_test.go
浏览文件 @
415aa2c6
...
@@ -152,3 +152,41 @@ func TestPinnerBasic(t *testing.T) {
...
@@ -152,3 +152,41 @@ func TestPinnerBasic(t *testing.T) {
t
.
Fatal
(
"could not find recursively pinned node"
)
t
.
Fatal
(
"could not find recursively pinned node"
)
}
}
}
}
func
TestDuplicateSemantics
(
t
*
testing
.
T
)
{
dstore
:=
dssync
.
MutexWrap
(
ds
.
NewMapDatastore
())
bstore
:=
blockstore
.
NewBlockstore
(
dstore
)
bserv
,
err
:=
bs
.
New
(
bstore
,
offline
.
Exchange
(
bstore
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dserv
:=
mdag
.
NewDAGService
(
bserv
)
// TODO does pinner need to share datastore with blockservice?
p
:=
NewPinner
(
dstore
,
dserv
)
a
,
_
:=
randNode
()
_
,
err
=
dserv
.
Add
(
a
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// pin is recursively
err
=
p
.
Pin
(
a
,
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// pinning directly should fail
err
=
p
.
Pin
(
a
,
false
)
if
err
==
nil
{
t
.
Fatal
(
"expected direct pin to fail"
)
}
// pinning recursively again should succeed
err
=
p
.
Pin
(
a
,
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
test/sharness/t0080-repo.sh
浏览文件 @
415aa2c6
...
@@ -48,6 +48,7 @@ test_expect_success "file no longer pinned" '
...
@@ -48,6 +48,7 @@ test_expect_success "file no longer pinned" '
# we expect the welcome files to show up here
# we expect the welcome files to show up here
echo "$HASH_WELCOME_DOCS" >expected2 &&
echo "$HASH_WELCOME_DOCS" >expected2 &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>expected2 &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>expected2 &&
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >> expected2 &&
sort expected2 >expected_sorted2 &&
sort expected2 >expected_sorted2 &&
ipfs pin ls -type=recursive >actual2 &&
ipfs pin ls -type=recursive >actual2 &&
sort actual2 >actual_sorted2 &&
sort actual2 >actual_sorted2 &&
...
@@ -127,7 +128,6 @@ test_expect_success "pin something directly" '
...
@@ -127,7 +128,6 @@ test_expect_success "pin something directly" '
test_expect_success
"'ipfs pin ls -type=direct' is correct"
'
test_expect_success
"'ipfs pin ls -type=direct' is correct"
'
echo "$DIRECTPIN" >directpinexpected &&
echo "$DIRECTPIN" >directpinexpected &&
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >>directpinexpected &&
sort directpinexpected >dp_exp_sorted &&
sort directpinexpected >dp_exp_sorted &&
ipfs pin ls -type=direct >directpinout &&
ipfs pin ls -type=direct >directpinout &&
sort directpinout >dp_out_sorted &&
sort directpinout >dp_out_sorted &&
...
@@ -137,6 +137,7 @@ test_expect_success "'ipfs pin ls -type=direct' is correct" '
...
@@ -137,6 +137,7 @@ test_expect_success "'ipfs pin ls -type=direct' is correct" '
test_expect_success
"'ipfs pin ls -type=recursive' is correct"
'
test_expect_success
"'ipfs pin ls -type=recursive' is correct"
'
echo "$MBLOCKHASH" >rp_expected &&
echo "$MBLOCKHASH" >rp_expected &&
echo "$HASH_WELCOME_DOCS" >>rp_expected &&
echo "$HASH_WELCOME_DOCS" >>rp_expected &&
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >>rp_expected &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>rp_expected &&
ipfs refs -r "$HASH_WELCOME_DOCS" >>rp_expected &&
sort rp_expected >rp_exp_sorted &&
sort rp_expected >rp_exp_sorted &&
ipfs pin ls -type=recursive >rp_actual &&
ipfs pin ls -type=recursive >rp_actual &&
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论