fix handling of filestore nodes in mfs during add
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Feb 10, 2017 at 23:55 UTC
e8764345d68bb0734d425b7e5f820c781c91144d
2 files changed
+23
core/coreunix/add.go
+5
@@ -21,6 +21,7 @@ import (
21
dag "github.com/ipfs/go-ipfs/merkledag"
22
mfs "github.com/ipfs/go-ipfs/mfs"
23
"github.com/ipfs/go-ipfs/pin"
24
+ posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo"
25
unixfs "github.com/ipfs/go-ipfs/unixfs"
26
27
ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
@@ -349,6 +350,10 @@ func (adder *Adder) addNode(node node.Node, path string) error {
350
path = node.Cid().String()
351
}
352
353
+ if pi, ok := node.(*posinfo.FilestoreNode); ok {
354
+ node = pi.Node
355
+ }
356
+
357
dir := gopath.Dir(path)
358
if dir != "." {
359
if err := mfs.Mkdir(adder.mr, dir, true, false); err != nil {
test/sharness/t0040-add-and-cat.sh
+18
@@ -207,6 +207,20 @@ test_add_named_pipe() {
207
'
208
}
209
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
+
224
test_add_pwd_is_symlink() {
225
test_expect_success "ipfs add -r adds directory content when ./ is symlink" '
226
mkdir hellodir &&
@@ -439,6 +453,8 @@ test_kill_ipfs_daemon
453
454
test_add_cat_file
455
456
+test_add_sharded_dir
457
+
458
test_add_cat_raw
459
460
test_expect_success "ipfs add --only-hash succeeds" '
@@ -459,6 +475,8 @@ test_launch_ipfs_daemon --offline
475
476
test_add_cat_file
477
478
+test_add_sharded_dir
479
+
480
test_kill_ipfs_daemon
481
482
test_done