diff --git a/commands/cli/parse.go b/commands/cli/parse.go index 25afa1f62b1..3bb9f8c145e 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -401,6 +401,10 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi if err != nil { return nil, err } + cwd, err = filepath.EvalSymlinks(cwd) + if err != nil { + return nil, err + } fpath = cwd } diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 92f001762eb..fb6f6e7a0f4 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -189,6 +189,18 @@ test_add_named_pipe() { ' } +test_add_pwd_is_symlink() { + test_expect_success "ipfs add -r adds directory content when ./ is symlink" ' + mkdir hellodir && + echo "World" > hellodir/world && + ln -s hellodir hellolink && + ( cd hellolink && + ipfs add -r . > ../actual ) && + grep "added Qma9CyFdG5ffrZCcYSin2uAETygB25cswVwEYYzwfQuhTe" actual && + rm -r hellodir + ' +} + test_launch_ipfs_daemon_and_mount test_expect_success "'ipfs add --help' succeeds" ' @@ -354,6 +366,8 @@ test_add_cat_expensive test_add_named_pipe " Post http://$API_ADDR/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true:" +test_add_pwd_is_symlink + test_kill_ipfs_daemon # should work offline @@ -371,6 +385,8 @@ test_expect_success "ipfs cat file fails" ' test_add_named_pipe "" +test_add_pwd_is_symlink + # Test daemon in offline mode test_launch_ipfs_daemon --offline