-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
00c3271
to
4ce81d6
Compare
I'd like to see a test for a path like: |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@whyrusleeping I don't understand. |
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 <kubuxu@protonmail.ch>
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
c7ab3fb
to
f35c53e
Compare
@whyrusleeping added the test and squashed test fixing with changes in the code. |
Cool, LGTM |
(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 | ||
' | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
This reverts commit fe7b01f. Conflicts: commands/cli/parse.go License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
This needs to be reverted. See #2839 (comment) |
Use a flag instead to get the behavior of resolving the link first. When in doubt, do what git does. |
Resolves #2839
License: MIT
Signed-off-by: Jakub Sztandera kubuxu@protonmail.ch