Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
8e7d9847
提交
8e7d9847
authored
1月 21, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updates from PR, tests tests tests!
上级
4de881a1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
76 行增加
和
24 行删除
+76
-24
repo.go
core/commands/repo.go
+9
-1
root.go
core/commands/root.go
+1
-1
gc.go
core/repo/gc.go
+3
-2
t0080-repo.sh
test/sharness/t0080-repo.sh
+63
-20
没有找到文件。
core/commands/repo.go
浏览文件 @
8e7d9847
...
...
@@ -42,11 +42,19 @@ order to reclaim hard disk space.
return
nil
,
err
}
o
utChan
,
err
:=
corerepo
.
GarbageCollectBlockstore
(
n
,
req
.
Context
()
.
Context
)
gcO
utChan
,
err
:=
corerepo
.
GarbageCollectBlockstore
(
n
,
req
.
Context
()
.
Context
)
if
err
!=
nil
{
return
nil
,
err
}
outChan
:=
make
(
chan
interface
{})
go
func
()
{
defer
close
(
outChan
)
for
k
:=
range
gcOutChan
{
outChan
<-
k
}
}()
return
outChan
,
nil
},
Type
:
corerepo
.
KeyRemoved
{},
...
...
core/commands/root.go
浏览文件 @
8e7d9847
...
...
@@ -81,7 +81,7 @@ var rootSubcommands = map[string]*cmds.Command{
"pin"
:
PinCmd
,
"ping"
:
PingCmd
,
"refs"
:
RefsCmd
,
"repo"
:
RepoCmd
,
"repo"
:
RepoCmd
,
"swarm"
:
SwarmCmd
,
"update"
:
UpdateCmd
,
"version"
:
VersionCmd
,
...
...
core/repo/gc.go
浏览文件 @
8e7d9847
...
...
@@ -14,14 +14,14 @@ type KeyRemoved struct {
Key
u
.
Key
}
func
GarbageCollectBlockstore
(
n
*
core
.
IpfsNode
,
ctx
context
.
Context
)
(
<-
chan
interface
{}
,
error
)
{
func
GarbageCollectBlockstore
(
n
*
core
.
IpfsNode
,
ctx
context
.
Context
)
(
<-
chan
*
KeyRemoved
,
error
)
{
keychan
,
err
:=
n
.
Blockstore
.
AllKeysChan
(
ctx
,
0
,
1
<<
16
)
if
err
!=
nil
{
return
nil
,
err
}
output
:=
make
(
chan
interface
{}
)
output
:=
make
(
chan
*
KeyRemoved
)
go
func
()
{
defer
close
(
output
)
for
{
...
...
@@ -34,6 +34,7 @@ func GarbageCollectBlockstore(n *core.IpfsNode, ctx context.Context) (<-chan int
err
:=
n
.
Blockstore
.
DeleteBlock
(
k
)
if
err
!=
nil
{
log
.
Errorf
(
"Error removing key from blockstore: %s"
,
err
)
continue
}
select
{
case
output
<-
&
KeyRemoved
{
k
}
:
...
...
test/sharness/t0080-repo.sh
浏览文件 @
8e7d9847
...
...
@@ -18,68 +18,111 @@ test_expect_success "'ipfs add afile' succeeds" '
'
test_expect_success
"added file was pinned"
'
ipfs pin ls -type=recursive | grep
`cat hashfile`
ipfs pin ls -type=recursive | grep
$HASH
'
test_expect_success
"'ipfs repo gc' doesnt remove file"
'
ipfs repo gc
ipfs cat `cat hashfile` > out
echo -n "" > empty
ipfs repo gc > gc_out_actual
test_cmp empty gc_out_actual
ipfs cat $HASH > out
test_cmp out afile
'
test_expect_success
"'ipfs pin rm' succeeds"
'
echo unpinned
`cat hashfile`
> expected1
ipfs pin rm -r
`cat hashfile`
> actual1
echo unpinned
$HASH
> expected1
ipfs pin rm -r
$HASH
> actual1
test_cmp expected1 actual1
'
test_expect_success
"file no longer pinned"
'
echo -n "" > expected2
ipfs pin ls -type=recursive > actual2
test_cmp e
xpected2
actual2
test_cmp e
mpty
actual2
'
test_expect_success
"recursively pin afile"
'
ipfs pin add -r
`cat hashfile`
ipfs pin add -r
$HASH
'
test_expect_success
"pinning directly should fail now"
'
echo Error: pin:
`cat hashfile`
already pinned recursively > expected3
ipfs pin add
`cat hashfile`
2> actual3
echo Error: pin:
$HASH
already pinned recursively > expected3
ipfs pin add
$HASH
2> actual3
test_cmp expected3 actual3
'
test_expect_success
"'ipfs pin rm <hash>' should fail"
'
echo Error:
`cat hashfile`
is pinned recursively > expected4
ipfs pin rm
`cat hashfile`
2> actual4
echo Error:
$HASH
is pinned recursively > expected4
ipfs pin rm
$HASH
2> actual4
test_cmp expected4 actual4
'
test_expect_success
"remove recursive pin, add direct"
'
echo unpinned
`cat hashfile`
> expected5
ipfs pin rm -r
`cat hashfile`
> actual5
echo unpinned
$HASH
> expected5
ipfs pin rm -r
$HASH
> actual5
test_cmp expected5 actual5
ipfs pin add
`cat hashfile`
ipfs pin add
$HASH
'
test_expect_success
"remove direct pin"
'
echo unpinned
`cat hashfile`
> expected6
ipfs pin rm
`cat hashfile`
> actual6
echo unpinned
$HASH
> expected6
ipfs pin rm
$HASH
> actual6
test_cmp expected6 actual6
'
test_expect_success
"'ipfs repo gc' removes file"
'
echo removed
`cat hashfile`
> expected7
echo removed
$HASH
> expected7
ipfs repo gc > actual7
test_cmp expected7 actual7
'
test_expect_success
"'ipfs refs local' no longer shows file"
'
echo -n "" > expected8
ipfs refs local > actual8
test_cmp e
xpected8
actual8
test_cmp e
mpty
actual8
'
test_expect_success
"adding multiblock random file succeeds"
'
random 1000000 > multiblock
MBLOCKHASH=`ipfs add -q multiblock`
'
test_expect_success
"'ipfs pin ls -type=indirect' is correct"
'
ipfs refs $MBLOCKHASH | sort > refsout
ipfs pin ls -type=indirect | sort > indirectpins
test_cmp refsout indirectpins
'
test_expect_success
"pin something directly"
'
echo "ipfs is so awesome" > awesome
DIRECTPIN=`ipfs add -q awesome`
echo unpinned $DIRECTPIN > expected9
ipfs pin rm -r $DIRECTPIN > actual9
test_cmp expected9 actual9
echo pinned $DIRECTPIN directly > expected10
ipfs pin add $DIRECTPIN > actual10
test_cmp expected10 actual10
'
test_expect_success
"'ipfs pin ls -type=direct' is correct"
'
echo $DIRECTPIN > directpinhash
ipfs pin ls -type=direct > directpinout
test_cmp directpinhash directpinout
'
test_expect_success
"'ipfs pin ls -type=recursive' is correct"
'
echo $MBLOCKHASH > rp_expected
ipfs pin ls -type=recursive > rp_actual
test_cmp rp_expected rp_actual
'
test_expect_success
"'ipfs pin ls -type=all' is correct"
'
cat directpinout > allpins
cat rp_actual >> allpins
cat indirectpins >> allpins
cat allpins | sort > allpins_sorted
ipfs pin ls -type=all | sort > actual_allpins
test_cmp allpins_sorted actual_allpins
'
test_kill_ipfs_daemon
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论