fix(cli): ipfs add with multiple files of same name (#8493)
Lucas Molas committed
Apr 3, 2022 at 11:40 UTC
282ac7f1f54df2d8f1576d02bc43fd60fa59cb1f
3 files changed
+24
-3
go.mod
+1
-1
@@ -31,7 +31,7 @@ require (
31
github.com/ipfs/go-graphsync v0.11.0
32
github.com/ipfs/go-ipfs-blockstore v1.2.0
33
github.com/ipfs/go-ipfs-chunker v0.0.5
34
- github.com/ipfs/go-ipfs-cmds v0.7.0
34
+ github.com/ipfs/go-ipfs-cmds v0.8.0
35
github.com/ipfs/go-ipfs-exchange-interface v0.1.0
36
github.com/ipfs/go-ipfs-exchange-offline v0.2.0
37
github.com/ipfs/go-ipfs-files v0.0.9
go.sum
+2
-2
@@ -473,8 +473,8 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtL
473
github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw=
474
github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8=
475
github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8=
476
-github.com/ipfs/go-ipfs-cmds v0.7.0 h1:0lEldmB7C83RxIOer38Sv1ob6wIoCAIEOaxiYgcv7wA=
477
-github.com/ipfs/go-ipfs-cmds v0.7.0/go.mod h1:y0bflH6m4g6ary4HniYt98UqbrVnRxmRarzeMdLIUn0=
476
+github.com/ipfs/go-ipfs-cmds v0.8.0 h1:M7apkPxhGe7I3rcKuQ8xRJLIPdaEqaZhJz0uPZEE8EU=
477
+github.com/ipfs/go-ipfs-cmds v0.8.0/go.mod h1:y0bflH6m4g6ary4HniYt98UqbrVnRxmRarzeMdLIUn0=
478
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
479
github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ=
480
github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
test/sharness/t0040-add-and-cat.sh
+21
@@ -345,6 +345,27 @@ test_add_cat_file() {
345
echo "added Qmf35k66MZNW2GijohUmXQEWKZU4cCGTCwK6idfnt152wJ hello2.txt" >> expected &&
346
test_cmp expected actual
347
'
348
+
349
+ test_expect_success "ipfs add with multiple files of same name succeeds" '
350
+ mkdir -p mountdir/same-file/ &&
351
+ cp mountdir/hello.txt mountdir/same-file/hello.txt &&
352
+ ipfs add mountdir/hello.txt mountdir/same-file/hello.txt >actual &&
353
+ rm mountdir/same-file/hello.txt &&
354
+ rmdir mountdir/same-file
355
+ '
356
+
357
+ test_expect_success "ipfs add with multiple files of same name output looks good" '
358
+ echo "added QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH hello.txt" >expected &&
359
+ test_cmp expected actual
360
+ '
361
+
362
+ test_must_fail "ipfs add with multiple files of same name but different dirs fails" '
363
+ mkdir -p mountdir/same-file/ &&
364
+ cp mountdir/hello.txt mountdir/same-file/hello.txt &&
365
+ ipfs add mountdir/hello.txt mountdir/same-file/hello.txt >actual &&
366
+ rm mountdir/same-file/hello.txt &&
367
+ rmdir mountdir/same-file
368
+ '
369
}
370
371
test_add_cat_5MB() {