Skip to content

Commit

Permalink
Fix "ipfs add -r ." to always add the contents of the current directory.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Aug 27, 2016
1 parent 88e4b11 commit 10a692f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commands/cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
16 changes: 16 additions & 0 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" '
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 10a692f

Please sign in to comment.