Skip to content

Commit 14e7424

Browse files
committed
fix handling of filestore nodes in mfs during add
License: MIT Signed-off-by: Jeromy <[email protected]>
1 parent 5edcd77 commit 14e7424

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

core/coreunix/add.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
dag "github.com/ipfs/go-ipfs/merkledag"
2222
mfs "github.com/ipfs/go-ipfs/mfs"
2323
"github.com/ipfs/go-ipfs/pin"
24+
posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo"
2425
unixfs "github.com/ipfs/go-ipfs/unixfs"
2526

2627
node "gx/ipfs/QmRSU5EqqWVZSNdbU51yXmVoF1uNw3JgTNB6RaiL7DZM16/go-ipld-node"
@@ -347,6 +348,10 @@ func (adder *Adder) addNode(node node.Node, path string) error {
347348
path = node.Cid().String()
348349
}
349350

351+
if pi, ok := node.(*posinfo.FilestoreNode); ok {
352+
node = pi.Node
353+
}
354+
350355
dir := gopath.Dir(path)
351356
if dir != "." {
352357
if err := mfs.Mkdir(adder.mr, dir, true, false); err != nil {

test/sharness/t0040-add-and-cat.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ test_add_named_pipe() {
207207
'
208208
}
209209

210+
test_add_sharded_dir() {
211+
mkdir testdata
212+
for i in `seq 2000`
213+
do
214+
echo $i > testdata/file$i
215+
done
216+
217+
test_expect_success "ipfs add on very large directory succeeds" '
218+
ipfs add -r -q testdata | tail -n1 > sharddir_out &&
219+
echo QmSCJD1KYLhVVHqBK3YyXuoEqHt7vggyJhzoFYbT8v1XYL > sharddir_exp &&
220+
test_cmp sharddir_exp sharddir_out
221+
'
222+
}
223+
210224
test_add_pwd_is_symlink() {
211225
test_expect_success "ipfs add -r adds directory content when ./ is symlink" '
212226
mkdir hellodir &&
@@ -430,6 +444,8 @@ test_kill_ipfs_daemon
430444

431445
test_add_cat_file
432446

447+
test_add_sharded_dir
448+
433449
test_add_cat_raw
434450

435451
test_expect_success "ipfs add --only-hash succeeds" '
@@ -450,6 +466,8 @@ test_launch_ipfs_daemon --offline
450466

451467
test_add_cat_file
452468

469+
test_add_sharded_dir
470+
453471
test_kill_ipfs_daemon
454472

455473
test_done

0 commit comments

Comments
 (0)