提交 b2a51684 作者: Łukasz Magiera 提交者: Steven Allen

Unixfs: enforce refs on files when using nocopy

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 19ca1a81
......@@ -116,7 +116,11 @@ time.
layout = trickle.Layout
}
root, err := layout(dbp.New(chk))
db, err := dbp.New(chk)
if err != nil {
return err
}
root, err := layout(db)
if err != nil {
return err
}
......
......@@ -16,6 +16,7 @@ import (
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs"
"gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs/importer/helpers"
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
cbor "gx/ipfs/QmRoARq3nkUb13HSKZGepCZSWe5GrVPwx7xURJGZ7KWv9V/go-ipld-cbor"
mdag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag"
......@@ -365,6 +366,13 @@ func (tp *provider) TestAdd(t *testing.T) {
opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true), options.Unixfs.RawLeaves(false)},
err: "nocopy option requires '--raw-leaves' to be enabled as well",
},
{
name: "noCopyNoPath",
data: strFile(helloStr),
path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd",
opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true)},
err: helpers.ErrMissingFsRef.Error(),
},
// Events / Progress
{
name: "simpleAddEvent",
......
......@@ -123,11 +123,15 @@ func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
CidBuilder: adder.CidBuilder,
}
db, err := params.New(chnk)
if err != nil {
return nil, err
}
if adder.Trickle {
return trickle.Layout(params.New(chnk))
return trickle.Layout(db)
}
return balanced.Layout(params.New(chnk))
return balanced.Layout(db)
}
// RootNode returns the root node of the Added.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论