Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve symlink if it is directly referenced in cli #2897

Merged
merged 2 commits into from
Jun 28, 2016

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Jun 23, 2016

Resolves #2839
License: MIT
Signed-off-by: Jakub Sztandera [email protected]

@Kubuxu Kubuxu added the status/in-progress In progress label Jun 23, 2016
@Kubuxu Kubuxu added this to the Ipfs 0.4.3 milestone Jun 23, 2016
@@ -418,7 +418,10 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi
}

fpath = filepath.ToSlash(filepath.Clean(fpath))

fpath, err := filepath.EvalSymlinks(fpath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this doesnt just resolve top level symlinks.

You could check if the final path element refers to a symlink and resolve it only in that case

Copy link
Member Author

@Kubuxu Kubuxu Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top level as directly referenced by user.

@Kubuxu Kubuxu force-pushed the feature/root-is-symlink branch 2 times, most recently from 00c3271 to 4ce81d6 Compare June 24, 2016 13:04
@Kubuxu Kubuxu added need/review Needs a review and removed status/in-progress In progress labels Jun 24, 2016
@whyrusleeping
Copy link
Member

I'd like to see a test for a path like: a/b/SYMLINK/c where 'c' is inside the folder that a symlink points to

test_cmp goodlink_exp goodlink_out
'

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still work? even with the changes youre making?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in this case we are adding symlink in recursive tree (not referenced directly by the command) this means that this symlink will not be resolved and added in the old way.

@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 28, 2016

@whyrusleeping I don't understand.

@whyrusleeping
Copy link
Member

Something like this:

mkdir -p a/b/c
ln -s a/b a/d
ipfs add a/d/c

Just to put some coverage on resolving a symlink thats in the middle of a path.

test: Directly referenced symlink should be resolved

License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 28, 2016

@whyrusleeping added the test and squashed test fixing with changes in the code.

@whyrusleeping
Copy link
Member

Cool, LGTM

@whyrusleeping
Copy link
Member

(waiting on tests to complete)

test_cmp filehash_exp filehash_out
'

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the intent of this test was really to add a symbolic link as there is limited support for them in the unixfs format.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think so too. we do want to be able to store symlinks eventually

kevina added a commit to ipfs-filestore/go-ipfs that referenced this pull request Aug 27, 2016
This reverts commit fe7b01f.

Conflicts:
	commands/cli/parse.go

License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
kevina added a commit to ipfs-filestore/go-ipfs that referenced this pull request Aug 27, 2016
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]>
@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

This needs to be reverted. See #2839 (comment)

@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

Use a flag instead to get the behavior of resolving the link first.

When in doubt, do what git does.

kevina added a commit that referenced this pull request Aug 27, 2016
This reverts commit fe7b01f.

Conflicts:
	commands/cli/parse.go

Revert "Merge pull request #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]>
@jbenet jbenet mentioned this pull request Aug 28, 2016
58 tasks
kevina added a commit that referenced this pull request Aug 29, 2016
Add back still useful test from reverted commit:
  fe7b01f
  Resolve symlink if it is directly referenced in cli (#2897)

License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
kevina added a commit that referenced this pull request Aug 29, 2016
Add back still useful test from reverted commit:
  fe7b01f
  Resolve symlink if it is directly referenced in cli (#2897)

License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants