Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ccb36277
提交
ccb36277
authored
1月 20, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pinning UX, and add tests to match
上级
5b20e86e
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
13 行删除
+24
-13
pinning.go
core/repo/pinning.go
+1
-1
pin.go
pin/pin.go
+12
-8
pin_test.go
pin/pin_test.go
+2
-2
t0080-repo.sh
test/sharness/t0080-repo.sh
+9
-2
没有找到文件。
core/repo/pinning.go
浏览文件 @
ccb36277
...
...
@@ -55,7 +55,7 @@ func Unpin(n *core.IpfsNode, paths []string, recursive bool) ([]u.Key, error) {
var
unpinned
[]
u
.
Key
for
_
,
dagnode
:=
range
dagnodes
{
k
,
_
:=
dagnode
.
Key
()
err
:=
n
.
Pinning
.
Unpin
(
k
)
err
:=
n
.
Pinning
.
Unpin
(
k
,
recursive
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pin/pin.go
浏览文件 @
ccb36277
...
...
@@ -31,7 +31,7 @@ const (
type
Pinner
interface
{
IsPinned
(
util
.
Key
)
bool
Pin
(
*
mdag
.
Node
,
bool
)
error
Unpin
(
util
.
Key
)
error
Unpin
(
util
.
Key
,
bool
)
error
Flush
()
error
GetManual
()
ManualPinner
DirectKeys
()
[]
util
.
Key
...
...
@@ -111,17 +111,21 @@ func (p *pinner) Pin(node *mdag.Node, recurse bool) error {
}
// Unpin a given key
func
(
p
*
pinner
)
Unpin
(
k
util
.
Key
)
error
{
func
(
p
*
pinner
)
Unpin
(
k
util
.
Key
,
recursive
bool
)
error
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
if
p
.
recursePin
.
HasKey
(
k
)
{
p
.
recursePin
.
RemoveBlock
(
k
)
node
,
err
:=
p
.
dserv
.
Get
(
k
)
if
err
!=
nil
{
return
err
if
recursive
{
p
.
recursePin
.
RemoveBlock
(
k
)
node
,
err
:=
p
.
dserv
.
Get
(
k
)
if
err
!=
nil
{
return
err
}
return
p
.
unpinLinks
(
node
)
}
else
{
return
errors
.
New
(
"Key pinned recursively."
)
}
return
p
.
unpinLinks
(
node
)
}
else
if
p
.
directPin
.
HasKey
(
k
)
{
p
.
directPin
.
RemoveBlock
(
k
)
return
nil
...
...
pin/pin_test.go
浏览文件 @
ccb36277
...
...
@@ -100,8 +100,8 @@ func TestPinnerBasic(t *testing.T) {
t
.
Fatal
(
"pinned node not found."
)
}
// Test unpin
err
=
p
.
Unpin
(
dk
)
// Test
recursive
unpin
err
=
p
.
Unpin
(
dk
,
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
test/sharness/t0080-repo.sh
浏览文件 @
ccb36277
...
...
@@ -25,7 +25,7 @@ test_expect_success "added file was pinned" '
test_expect_success
"'ipfs pin rm' succeeds"
'
echo Unpinned `cat hashfile` > expected
ipfs pin rm `cat hashfile` > actual
ipfs pin rm
-r
`cat hashfile` > actual
test_cmp expected actual
'
...
...
@@ -45,14 +45,21 @@ test_expect_success "pinning directly should fail now" '
test_cmp expected actual
'
test_expect_success
"'ipfs pin rm <hash>' should fail"
'
echo Error: Key pinned recursively. > expected
ipfs pin rm `cat hashfile` 2> error
test_cmp expected error
'
test_expect_success
"remove recursive pin, add direct"
'
echo Unpinned `cat hashfile` > expected
ipfs pin rm `cat hashfile` > actual
ipfs pin rm
-r
`cat hashfile` > actual
test_cmp expected actual
ipfs pin add `cat hashfile`
'
test_expect_success
"remove direct pin"
'
echo Unpinned `cat hashfile` > expected
ipfs pin rm `cat hashfile` > actual
test_cmp expected actual
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论