Skip to content

Commit

Permalink
Revert "Resolve symlink if it is directly referenced in cli (ipfs#2897)"
Browse files Browse the repository at this point in the history
This reverts commit fe7b01f.

Conflicts:
	commands/cli/parse.go

Revert "Merge pull request ipfs#3023 from ipfs/feature/eval-symlink-windows"

This reverts commit 16c5a89, reversing
changes made to 8c77ff8.

Conflicts:
	commands/cli/parse.go

License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
  • Loading branch information
kevina committed Aug 27, 2016
1 parent 0b6dc58 commit 9090771
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
8 changes: 1 addition & 7 deletions commands/cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,7 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi
fpath = cwd
}

fpath = filepath.Clean(fpath)
fpath, err := filepath.EvalSymlinks(fpath)
if err != nil {
return nil, err
}
// Repeat ToSlash after EvalSymlinks as it turns path to platform specific
fpath = filepath.ToSlash(fpath)
fpath = filepath.ToSlash(filepath.Clean(fpath))

stat, err := os.Lstat(fpath)
if err != nil {
Expand Down
23 changes: 6 additions & 17 deletions test/sharness/t0044-add-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ test_description="Test add -w"
test_expect_success "creating files succeeds" '
mkdir -p files/foo &&
mkdir -p files/bar &&
mkdir -p files/badin
echo "some text" > files/foo/baz &&
ln -s ../foo/baz files/bar/baz &&
ln -s files/does/not/exist files/badin/bad &&
mkdir -p files2/a/b/c &&
echo "some other text" > files2/a/b/c/foo &&
ln -s b files2/a/d
ln -s files/foo/baz files/bar/baz &&
ln -s files/does/not/exist files/bad
'

test_add_symlinks() {
Expand All @@ -27,34 +23,27 @@ test_add_symlinks() {
'

test_expect_success "output looks good" '
echo QmQRgZT6xVFKJLVVpJDu3WcPkw2iqQ1jqK1F9jmdeq9zAv > filehash_exp &&
echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp &&
test_cmp filehash_exp filehash_out
'

test_expect_success "adding a symlink adds the file itself" '
test_expect_success "adding a symlink adds the link itself" '
ipfs add -q files/bar/baz > goodlink_out
'

test_expect_success "output looks good" '
echo QmcPNXE5zjkWkM24xQ7Bi3VAm8fRxiaNp88jFsij7kSQF1 > goodlink_exp &&
echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp &&
test_cmp goodlink_exp goodlink_out
'

test_expect_success "adding a broken symlink works" '
ipfs add -qr files/badin | head -1 > badlink_out
ipfs add -q files/bad > badlink_out
'

test_expect_success "output looks good" '
echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp &&
test_cmp badlink_exp badlink_out
'

test_expect_success "adding with symlink in middle of path is same as\
adding with no symlink" '
ipfs add -rq files2/a/b/c > no_sym &&
ipfs add -rq files2/a/d/c > sym &&
test_cmp no_sym sym
'
}

test_init_ipfs
Expand Down

0 comments on commit 9090771

Please sign in to comment.