Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
f2fbfdf2
提交
f2fbfdf2
authored
8月 16, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mfs: inherit CID prefix from from parent directory
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
77e9b8dd
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
40 行增加
和
7 行删除
+40
-7
files.go
core/commands/files/files.go
+2
-0
dir.go
mfs/dir.go
+6
-0
file.go
mfs/file.go
+8
-3
ops.go
mfs/ops.go
+6
-2
t0260-sharding-flag.sh
test/sharness/t0260-sharding-flag.sh
+2
-2
hamt.go
unixfs/hamt/hamt.go
+7
-0
dirbuilder.go
unixfs/io/dirbuilder.go
+9
-0
没有找到文件。
core/commands/files/files.go
浏览文件 @
f2fbfdf2
...
...
@@ -890,8 +890,10 @@ func getFileHandle(r *mfs.Root, path string, create bool) (*mfs.File, error) {
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"%s was not a directory"
,
dirname
)
}
prefix
:=
pdir
.
GetPrefix
()
nd
:=
dag
.
NodeWithData
(
ft
.
FilePBData
(
nil
,
0
))
nd
.
SetPrefix
(
prefix
)
err
=
pdir
.
AddChild
(
fname
,
nd
)
if
err
!=
nil
{
return
nil
,
err
...
...
mfs/dir.go
浏览文件 @
f2fbfdf2
...
...
@@ -58,6 +58,11 @@ func NewDirectory(ctx context.Context, name string, node node.Node, parent child
},
nil
}
// GetPrefix gets the CID prefix of the root node
func
(
d
*
Directory
)
GetPrefix
()
*
cid
.
Prefix
{
return
d
.
dirbuilder
.
GetPrefix
()
}
// SetPrefix sets the CID prefix
func
(
d
*
Directory
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
d
.
dirbuilder
.
SetPrefix
(
prefix
)
...
...
@@ -299,6 +304,7 @@ func (d *Directory) Mkdir(name string) (*Directory, error) {
}
ndir
:=
ft
.
EmptyDirNode
()
ndir
.
SetPrefix
(
d
.
GetPrefix
())
_
,
err
=
d
.
dserv
.
Add
(
ndir
)
if
err
!=
nil
{
...
...
mfs/file.go
浏览文件 @
f2fbfdf2
...
...
@@ -27,14 +27,19 @@ type File struct {
RawLeaves
bool
}
// NewFile returns a NewFile object with the given parameters
// NewFile returns a NewFile object with the given parameters. If the
// Cid version is non-zero RawLeaves will be enabled.
func
NewFile
(
name
string
,
node
node
.
Node
,
parent
childCloser
,
dserv
dag
.
DAGService
)
(
*
File
,
error
)
{
return
&
File
{
fi
:=
&
File
{
dserv
:
dserv
,
parent
:
parent
,
name
:
name
,
node
:
node
,
},
nil
}
if
node
.
Cid
()
.
Prefix
()
.
Version
>
0
{
fi
.
RawLeaves
=
true
}
return
fi
,
nil
}
const
(
...
...
mfs/ops.go
浏览文件 @
f2fbfdf2
...
...
@@ -129,7 +129,9 @@ func Mkdir(r *Root, pth string, mkparents bool, flush bool) error {
if
err
!=
nil
{
return
err
}
mkd
.
SetPrefix
(
r
.
Prefix
)
if
r
.
Prefix
!=
nil
{
mkd
.
SetPrefix
(
r
.
Prefix
)
}
fsn
=
mkd
}
else
if
err
!=
nil
{
return
err
...
...
@@ -148,7 +150,9 @@ func Mkdir(r *Root, pth string, mkparents bool, flush bool) error {
return
err
}
}
final
.
SetPrefix
(
r
.
Prefix
)
if
r
.
Prefix
!=
nil
{
final
.
SetPrefix
(
r
.
Prefix
)
}
if
flush
{
err
:=
final
.
Flush
()
...
...
test/sharness/t0260-sharding-flag.sh
浏览文件 @
f2fbfdf2
...
...
@@ -75,8 +75,8 @@ test_add_large_dir_v1() {
'
}
# this hash implies
both the directory and the leaf entries are CIDv1
SHARDEDV1
=
"zdj7W
X91spg4DsnNpvoBLjyjXUGgcTTWavygBbSifpmJdgPUA
"
# this hash implies
the directory is CIDv1 and leaf entries are CIDv1 and raw
SHARDEDV1
=
"zdj7W
Y8aNcxF49q1ZpFXfchNmbswnUxiVDVjmrHb53xRM8W4C
"
test_add_large_dir_v1
"
$SHARDEDV1
"
test_launch_ipfs_daemon
...
...
unixfs/hamt/hamt.go
浏览文件 @
f2fbfdf2
...
...
@@ -121,6 +121,7 @@ func NewHamtFromDag(dserv dag.DAGService, nd node.Node) (*HamtShard, error) {
ds
.
children
=
make
([]
child
,
len
(
pbnd
.
Links
()))
ds
.
bitfield
=
new
(
big
.
Int
)
.
SetBytes
(
pbd
.
GetData
())
ds
.
hashFunc
=
pbd
.
GetHashType
()
ds
.
prefix
=
&
ds
.
nd
.
Prefix
return
ds
,
nil
}
...
...
@@ -130,6 +131,11 @@ func (ds *HamtShard) SetPrefix(prefix *cid.Prefix) {
ds
.
prefix
=
prefix
}
// GetPrefix gets the CID Prefix, may be nil if unset
func
(
ds
*
HamtShard
)
Prefix
()
*
cid
.
Prefix
{
return
ds
.
prefix
}
// Node serializes the HAMT structure into a merkledag node with unixfs formatting
func
(
ds
*
HamtShard
)
Node
()
(
node
.
Node
,
error
)
{
out
:=
new
(
dag
.
ProtoNode
)
...
...
@@ -500,6 +506,7 @@ func (ds *HamtShard) modifyValue(ctx context.Context, hv *hashBits, key string,
if
err
!=
nil
{
return
err
}
ns
.
prefix
=
ds
.
prefix
chhv
:=
&
hashBits
{
b
:
hash
([]
byte
(
child
.
key
)),
consumed
:
hv
.
consumed
,
...
...
unixfs/io/dirbuilder.go
浏览文件 @
f2fbfdf2
...
...
@@ -115,6 +115,7 @@ func (d *Directory) switchToSharding(ctx context.Context) error {
if
err
!=
nil
{
return
err
}
s
.
SetPrefix
(
&
d
.
dirnode
.
Prefix
)
d
.
shard
=
s
for
_
,
lnk
:=
range
d
.
dirnode
.
Links
()
{
...
...
@@ -192,3 +193,11 @@ func (d *Directory) GetNode() (node.Node, error) {
return
d
.
shard
.
Node
()
}
func
(
d
*
Directory
)
GetPrefix
()
*
cid
.
Prefix
{
if
d
.
shard
==
nil
{
return
&
d
.
dirnode
.
Prefix
}
return
d
.
shard
.
Prefix
()
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论