From 5d7e8a893d5b0fd1b681780070e397720c110c76 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Thu, 1 Mar 2018 23:45:44 -0300 Subject: [PATCH] add: hash-only: set the prefix for MFS root Fixes #4652. License: MIT Signed-off-by: Lucas Molas --- core/commands/add.go | 5 ++++- test/sharness/t0043-add-w.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/commands/add.go b/core/commands/add.go index 22171d9a5..4ef6b3c0d 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -283,7 +283,10 @@ You can now check what blocks have been created by: if hash { md := dagtest.Mock() - mr, err := mfs.NewRoot(req.Context, md, ft.EmptyDirNode(), nil) + emptyDirNode := ft.EmptyDirNode() + // Use the same prefix for the "empty" MFS root as for the file adder. + emptyDirNode.Prefix = *fileAdder.Prefix + mr, err := mfs.NewRoot(req.Context, md, emptyDirNode, nil) if err != nil { res.SetError(err, cmdkit.ErrNormal) return diff --git a/test/sharness/t0043-add-w.sh b/test/sharness/t0043-add-w.sh index cd4b5d1e5..37f72524e 100755 --- a/test/sharness/t0043-add-w.sh +++ b/test/sharness/t0043-add-w.sh @@ -149,6 +149,15 @@ test_add_w() { echo "$add_w_d1_v1" >expected && test_sort_cmp expected actual ' + + test_expect_success "ipfs add -w -r -n (dir) --cid-version=1 succeeds" ' + ipfs add -r -w -n --cid-version=1 m/t_1wp-8a2/_jo7 >actual + ' + + test_expect_success "ipfs add -w -r -n (dir) --cid-version=1 is correct" ' + echo "$add_w_d1_v1" > expected && + test_sort_cmp expected actual + ' } test_init_ipfs