Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/sharness/t0043-add-w.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down