Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
25a0db4f
提交
25a0db4f
authored
12月 10, 2018
作者:
Steven Allen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pinning support to the urlstore
fixes #5833 License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
上级
7956adad
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
9 行删除
+21
-9
urlstore.go
core/commands/urlstore.go
+18
-4
t0272-urlstore.sh
test/sharness/t0272-urlstore.sh
+3
-5
没有找到文件。
core/commands/urlstore.go
浏览文件 @
25a0db4f
...
...
@@ -7,6 +7,7 @@ import (
cmdenv
"github.com/ipfs/go-ipfs/core/commands/cmdenv"
filestore
"github.com/ipfs/go-ipfs/filestore"
pin
"github.com/ipfs/go-ipfs/pin"
chunk
"gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker"
cid
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
...
...
@@ -36,9 +37,6 @@ control.
The file is added using raw-leaves but otherwise using the default
settings for 'ipfs add'.
The file is not pinned, so this command should be followed by an 'ipfs
pin add'.
This command is considered temporary until a better solution can be
found. It may disappear or the semantics can change at any
time.
...
...
@@ -46,6 +44,7 @@ time.
},
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
trickleOptionName
,
"t"
,
"Use trickle-dag format for dag generation."
),
cmdkit
.
BoolOption
(
pinOptionName
,
"Pin this object when adding."
)
.
WithDefault
(
true
),
},
Arguments
:
[]
cmdkit
.
Argument
{
cmdkit
.
StringArg
(
"url"
,
true
,
false
,
"URL to add to IPFS"
),
...
...
@@ -73,6 +72,7 @@ time.
}
useTrickledag
,
_
:=
req
.
Options
[
trickleOptionName
]
.
(
bool
)
dopin
,
_
:=
req
.
Options
[
pinOptionName
]
.
(
bool
)
hreq
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
...
...
@@ -87,6 +87,11 @@ time.
return
fmt
.
Errorf
(
"expected code 200, got: %d"
,
hres
.
StatusCode
)
}
if
dopin
{
// Take the pinlock
defer
n
.
Blockstore
.
PinLock
()
.
Unlock
()
}
chk
:=
chunk
.
NewSizeSplitter
(
hres
.
Body
,
chunk
.
DefaultBlockSize
)
prefix
:=
cid
.
NewPrefixV1
(
cid
.
DagProtobuf
,
mh
.
SHA2_256
)
dbp
:=
&
ihelper
.
DagBuilderParams
{
...
...
@@ -102,13 +107,22 @@ time.
if
useTrickledag
{
layout
=
trickle
.
Layout
}
root
,
err
:=
layout
(
dbp
.
New
(
chk
))
if
err
!=
nil
{
return
err
}
c
:=
root
.
Cid
()
if
dopin
{
n
.
Pinning
.
PinWithMode
(
c
,
pin
.
Recursive
)
if
err
:=
n
.
Pinning
.
Flush
();
err
!=
nil
{
return
err
}
}
return
cmds
.
EmitOnce
(
res
,
&
BlockStat
{
Key
:
root
.
Cid
()
.
String
(),
Key
:
c
.
String
(),
Size
:
int
(
hres
.
ContentLength
),
})
},
...
...
test/sharness/t0272-urlstore.sh
浏览文件 @
25a0db4f
...
...
@@ -46,9 +46,8 @@ test_expect_success "enable urlstore" '
test_launch_ipfs_daemon
--offline
test_expect_success
"add files using gateway address via url store"
'
HASH1=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) &&
HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a) &&
ipfs pin add $HASH1 $HASH2
HASH1=$(ipfs urlstore add --pin=false http://127.0.0.1:$GWAY_PORT/ipfs/$HASH1a) &&
HASH2=$(ipfs urlstore add http://127.0.0.1:$GWAY_PORT/ipfs/$HASH2a)
'
test_expect_success
"make sure hashes are different"
'
...
...
@@ -99,7 +98,6 @@ test_expect_success "gatway no longer has files" '
cat
<<
EOF
| sort > verify_expect_2
error zb2rhX1q5oFFzEkPNsTe1Y8osUdFqSQGjUWRZsqC9fbY6WVSk 262144 http://127.0.0.1:
$GWAY_PORT
/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 0
error zb2rhYbKFn1UWGHXaAitcdVTkDGTykX8RFpGWzRFuLpoe9VE4 237856 http://127.0.0.1:
$GWAY_PORT
/ipfs/QmUow2T4P69nEsqTQDZCt8yg9CPS8GFmpuDAr5YtsPhTdM 262144
error zb2rhjddJ5DNzBrFu8G6CP1ApY25BukwCeskXHzN1H18CiVVZ 2222 http://127.0.0.1:
$GWAY_PORT
/ipfs/QmcHm3BL2cXuQ6rJdKQgPrmT9suqGkfy2KzH3MkXPEBXU6 0
EOF
test_expect_success
"ipfs filestore verify is correct"
'
...
...
@@ -113,7 +111,7 @@ test_expect_success "files can not be retrieved via the urlstore" '
'
test_expect_success
"remove broken files"
'
ipfs pin rm $HASH
1 $HASH
2 &&
ipfs pin rm $HASH2 &&
ipfs repo gc > /dev/null
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论