@cryptotaxi247 / kubo / commits / b2a516846

Unixfs: enforce refs on files when using nocopy

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Jan 14, 2019 at 22:00 UTC b2a516846899801ee06eaff73fe9374848b55f68
3 files changed +19 -3
core/commands/urlstore.go
+5 -1
@@ -116,7 +116,11 @@ time.
116 layout = trickle.Layout
117 }
118
119 - root, err := layout(dbp.New(chk))
119 + db, err := dbp.New(chk)
120 + if err != nil {
121 + return err
122 + }
123 + root, err := layout(db)
124 if err != nil {
125 return err
126 }
core/coreapi/interface/tests/unixfs.go
+8
@@ -16,6 +16,7 @@ import (
16 "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
17
18 "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs"
19 + "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs/importer/helpers"
20 "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
21 cbor "gx/ipfs/QmRoARq3nkUb13HSKZGepCZSWe5GrVPwx7xURJGZ7KWv9V/go-ipld-cbor"
22 mdag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag"
@@ -365,6 +366,13 @@ func (tp *provider) TestAdd(t *testing.T) {
366 opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true), options.Unixfs.RawLeaves(false)},
367 err: "nocopy option requires '--raw-leaves' to be enabled as well",
368 },
369 + {
370 + name: "noCopyNoPath",
371 + data: strFile(helloStr),
372 + path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd",
373 + opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true)},
374 + err: helpers.ErrMissingFsRef.Error(),
375 + },
376 // Events / Progress
377 {
378 name: "simpleAddEvent",
core/coreunix/add.go
+6 -2
@@ -123,11 +123,15 @@ func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
123 CidBuilder: adder.CidBuilder,
124 }
125
126 + db, err := params.New(chnk)
127 + if err != nil {
128 + return nil, err
129 + }
130 if adder.Trickle {
127 - return trickle.Layout(params.New(chnk))
131 + return trickle.Layout(db)
132 }
133
130 - return balanced.Layout(params.New(chnk))
134 + return balanced.Layout(db)
135 }
136
137 // RootNode returns the root node of the Added.