@cryptotaxi247 / kubo / commits / 5d7e8a893

add: hash-only: set the prefix for MFS root

Fixes #4652. License: MIT Signed-off-by: Lucas Molas <schomatis@gmail.com>

Lucas Molas committed Mar 1, 2018 at 23:45 UTC 5d7e8a893d5b0fd1b681780070e397720c110c76
2 files changed +13 -1
core/commands/add.go
+4 -1
@@ -283,7 +283,10 @@ You can now check what blocks have been created by:
283
284 if hash {
285 md := dagtest.Mock()
286 - mr, err := mfs.NewRoot(req.Context, md, ft.EmptyDirNode(), nil)
286 + emptyDirNode := ft.EmptyDirNode()
287 + // Use the same prefix for the "empty" MFS root as for the file adder.
288 + emptyDirNode.Prefix = *fileAdder.Prefix
289 + mr, err := mfs.NewRoot(req.Context, md, emptyDirNode, nil)
290 if err != nil {
291 res.SetError(err, cmdkit.ErrNormal)
292 return
test/sharness/t0043-add-w.sh
+9
@@ -149,6 +149,15 @@ test_add_w() {
149 echo "$add_w_d1_v1" >expected &&
150 test_sort_cmp expected actual
151 '
152 +
153 + test_expect_success "ipfs add -w -r -n (dir) --cid-version=1 succeeds" '
154 + ipfs add -r -w -n --cid-version=1 m/t_1wp-8a2/_jo7 >actual
155 + '
156 +
157 + test_expect_success "ipfs add -w -r -n (dir) --cid-version=1 is correct" '
158 + echo "$add_w_d1_v1" > expected &&
159 + test_sort_cmp expected actual
160 + '
161 }
162
163 test_init_ipfs