Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
f7efb34e
提交
f7efb34e
authored
2月 06, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
filestore util: Add 'filestore dups' command. Enhance tests.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
1f2e174e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
69 行增加
和
1 行删除
+69
-1
filestore.go
core/commands/filestore.go
+40
-0
filestore.go
filestore/filestore.go
+8
-0
t0271-filestore-utils.sh
test/sharness/t0271-filestore-utils.sh
+21
-1
没有找到文件。
core/commands/filestore.go
浏览文件 @
f7efb34e
...
...
@@ -18,6 +18,7 @@ var FileStoreCmd = &cmds.Command{
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"ls"
:
lsFileStore
,
"verify"
:
verifyFileStore
,
"dups"
:
dupsFileStore
,
},
}
...
...
@@ -157,6 +158,44 @@ For ERROR entries the error will also be printed to stderr.
Type
:
filestore
.
ListRes
{},
}
var
dupsFileStore
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Print block both in filestore and non-filestore."
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
_
,
fs
,
err
:=
getFilestore
(
req
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
ch
,
err
:=
fs
.
FileManager
()
.
AllKeysChan
(
req
.
Context
())
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
out
:=
make
(
chan
interface
{},
128
)
res
.
SetOutput
((
<-
chan
interface
{})(
out
))
go
func
()
{
defer
close
(
out
)
for
cid
:=
range
ch
{
have
,
err
:=
fs
.
MainBlockstore
()
.
Has
(
cid
)
if
err
!=
nil
{
out
<-
&
RefWrapper
{
Err
:
err
.
Error
()}
return
}
if
have
{
out
<-
&
RefWrapper
{
Ref
:
cid
.
String
()}
}
}
}()
},
Marshalers
:
refsMarshallerMap
,
Type
:
RefWrapper
{},
}
func
getFilestore
(
req
cmds
.
Request
)
(
*
core
.
IpfsNode
,
*
filestore
.
Filestore
,
error
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
...
...
@@ -211,3 +250,4 @@ func perKeyActionToChan(args []string, action func(*cid.Cid) *filestore.ListRes,
}()
return
out
}
filestore/filestore.go
浏览文件 @
f7efb34e
...
...
@@ -19,6 +19,14 @@ type Filestore struct {
bs
blockstore
.
Blockstore
}
func
(
f
*
Filestore
)
FileManager
()
*
FileManager
{
return
f
.
fm
}
func
(
f
*
Filestore
)
MainBlockstore
()
blockstore
.
Blockstore
{
return
f
.
bs
}
func
NewFilestore
(
bs
blockstore
.
Blockstore
,
fm
*
FileManager
)
*
Filestore
{
return
&
Filestore
{
fm
,
bs
}
}
...
...
test/sharness/t0271-filestore-
verify
.sh
→
test/sharness/t0271-filestore-
utils
.sh
浏览文件 @
f7efb34e
...
...
@@ -115,6 +115,18 @@ test_filestore_verify() {
'
}
cat
<<
EOF
> dups_expect
$FILE1_HASH
EOF
test_filestore_dups
()
{
test_expect_success
"'ipfs filestore dups'"
'
ipfs add --raw-leaves somedir/file1 &&
ipfs filestore dups > dups_actual &&
test_cmp dups_expect dups_actual
'
}
init_ipfs_filestore
()
{
test_expect_success
"clean up old node"
'
rm -rf "$IPFS_PATH" mountdir ipfs ipns
...
...
@@ -135,6 +147,8 @@ test_filestore_adds
test_filestore_verify
test_filestore_dups
echo
"WORKING DIR"
echo
"IPFS PATH = "
$IPFS_PATH
pwd
...
...
@@ -144,10 +158,16 @@ test_init_dataset
init_ipfs_filestore
test_launch_ipfs_daemon
# must be in offline mode so tests of retrieving non-exist blocks
# don't hang
test_launch_ipfs_daemon
--offline
test_filestore_adds
test_filestore_verify
test_filestore_dups
test_kill_ipfs_daemon
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论