From a27afcf3b3a8ab3d88dc95b61c78b4bf7862f058 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Wed, 6 Oct 2021 11:52:17 -0300 Subject: [PATCH] fix(cli): ipfs add with multiple files of same name --- go.mod | 2 +- go.sum | 4 ++-- test/sharness/t0040-add-and-cat.sh | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ea335814d6..805e60ab990 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/ipfs/go-graphsync v0.11.0 github.com/ipfs/go-ipfs-blockstore v1.1.2 github.com/ipfs/go-ipfs-chunker v0.0.5 - github.com/ipfs/go-ipfs-cmds v0.6.0 + github.com/ipfs/go-ipfs-cmds v0.6.1-0.20211005151237-0e6ec5a05153 github.com/ipfs/go-ipfs-config v0.18.0 github.com/ipfs/go-ipfs-exchange-interface v0.1.0 github.com/ipfs/go-ipfs-exchange-offline v0.1.1 diff --git a/go.sum b/go.sum index 49a1addffe4..88f46e6c9b4 100644 --- a/go.sum +++ b/go.sum @@ -473,8 +473,8 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtL github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw= github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8= github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8= -github.com/ipfs/go-ipfs-cmds v0.6.0 h1:yAxdowQZzoFKjcLI08sXVNnqVj3jnABbf9smrPQmBsw= -github.com/ipfs/go-ipfs-cmds v0.6.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk= +github.com/ipfs/go-ipfs-cmds v0.6.1-0.20211005151237-0e6ec5a05153 h1:CPOUY849Eac0NbZqaBrvZE8LVtXe878OQw1XzgCC4Mg= +github.com/ipfs/go-ipfs-cmds v0.6.1-0.20211005151237-0e6ec5a05153/go.mod h1:y0bflH6m4g6ary4HniYt98UqbrVnRxmRarzeMdLIUn0= github.com/ipfs/go-ipfs-config v0.18.0 h1:Ta1aNGNEq6RIvzbw7dqzCVZJKb7j+Dd35JFnAOCpT8g= github.com/ipfs/go-ipfs-config v0.18.0/go.mod h1:wz2lKzOjgJeYJa6zx8W9VT7mz+iSd0laBMqS/9wmX6A= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 635b97453a9..7e69d83cc12 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -345,6 +345,23 @@ test_add_cat_file() { echo "added Qmf35k66MZNW2GijohUmXQEWKZU4cCGTCwK6idfnt152wJ hello2.txt" >> expected && test_cmp expected actual ' + + test_expect_success "ipfs add with multiple files of same name succeeds" ' + mkdir -p mountdir/same-file/ && + mkdir -p mountdir/hello2-content/ && + cp mountdir/hello.txt mountdir/same-file/hello.txt && + cp mountdir/hello2.txt mountdir/hello2-content/hello.txt && + ipfs add mountdir/hello.txt mountdir/same-file/hello.txt mountdir/hello2-content/hello.txt >actual && + rm mountdir/same-file/hello.txt mountdir/hello2-content/hello.txt && + rmdir mountdir/same-file mountdir/hello2-content + ' + + test_expect_success "ipfs add with multiple files of same name output looks good" ' + echo "added QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH hello.txt" >expected && + echo "added QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH hello.txt" >>expected && + echo "added Qmf35k66MZNW2GijohUmXQEWKZU4cCGTCwK6idfnt152wJ hello.txt" >> expected && + test_cmp expected actual + ' } test_add_cat_5MB() {