Skip to content

Commit 59ad0f8

Browse files
Merge pull request #4755 from schomatis/fix/add/hash-only
add: hash-only: set the prefix for MFS root
2 parents c44191e + 5d7e8a8 commit 59ad0f8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/commands/add.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ You can now check what blocks have been created by:
283283

284284
if hash {
285285
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)
287290
if err != nil {
288291
res.SetError(err, cmdkit.ErrNormal)
289292
return

test/sharness/t0043-add-w.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ test_add_w() {
149149
echo "$add_w_d1_v1" >expected &&
150150
test_sort_cmp expected actual
151151
'
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+
'
152161
}
153162

154163
test_init_ipfs

0 commit comments

Comments
 (0)