Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
42156532
Unverified
提交
42156532
authored
7月 23, 2018
作者:
Whyrusleeping
提交者:
GitHub
7月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5271 from ipfs/fix/5270
Fix resolving links in sharded directories on gateway
上级
80fcc4ec
d4936244
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
42 行增加
和
12 行删除
+42
-12
resolver.go
path/resolver/resolver.go
+33
-12
t0260-sharding.sh
test/sharness/t0260-sharding.sh
+9
-0
没有找到文件。
path/resolver/resolver.go
浏览文件 @
42156532
...
@@ -69,25 +69,46 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (ipld
...
@@ -69,25 +69,46 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (ipld
}
}
for
len
(
p
)
>
0
{
for
len
(
p
)
>
0
{
val
,
rest
,
err
:=
nd
.
Resolve
(
p
)
lnk
,
rest
,
err
:=
r
.
ResolveOnce
(
ctx
,
r
.
DAG
,
nd
,
p
)
// Note: have to drop the error here as `ResolveOnce` doesn't handle 'leaf'
// paths (so e.g. for `echo '{"foo":123}' | ipfs dag put` we wouldn't be
// able to resolve `zdpu[...]/foo`)
if
lnk
==
nil
{
break
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
switch
val
:=
val
.
(
type
)
{
next
,
err
:=
lnk
.
GetNode
(
ctx
,
r
.
DAG
)
case
*
ipld
.
Link
:
if
err
!=
nil
{
next
,
err
:=
val
.
GetNode
(
ctx
,
r
.
DAG
)
return
nil
,
nil
,
err
if
err
!=
nil
{
return
nil
,
nil
,
err
}
nd
=
next
p
=
rest
default
:
return
nd
,
p
,
nil
}
}
nd
=
next
p
=
rest
}
if
len
(
p
)
==
0
{
return
nd
,
nil
,
nil
}
}
return
nd
,
nil
,
nil
// Confirm the path exists within the object
val
,
rest
,
err
:=
nd
.
Resolve
(
p
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
if
len
(
rest
)
>
0
{
return
nil
,
nil
,
errors
.
New
(
"path failed to resolve fully"
)
}
switch
val
.
(
type
)
{
case
*
ipld
.
Link
:
return
nil
,
nil
,
errors
.
New
(
"inconsistent ResolveOnce / nd.Resolve"
)
default
:
return
nd
,
p
,
nil
}
}
}
// ResolvePath fetches the node for given path. It returns the last item
// ResolvePath fetches the node for given path. It returns the last item
...
...
test/sharness/t0260-sharding.sh
浏览文件 @
42156532
...
@@ -76,6 +76,15 @@ test_expect_success "'ipfs ls --resolve-type=false' admits missing block" '
...
@@ -76,6 +76,15 @@ test_expect_success "'ipfs ls --resolve-type=false' admits missing block" '
test_cmp sharded_out missing_out
test_cmp sharded_out missing_out
'
'
test_launch_ipfs_daemon
test_expect_success
"gateway can resolve sharded dirs"
'
echo 100 > expected &&
curl -sfo actual "http://127.0.0.1:$GWAY_PORT/ipfs/$SHARDED/file100" &&
test_cmp expected actual
'
test_kill_ipfs_daemon
test_add_large_dir_v1
()
{
test_add_large_dir_v1
()
{
exphash
=
"
$1
"
exphash
=
"
$1
"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论