Skip to content
New issue

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

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

Already on GitHub? # to your account

bug fix: silently fails overwriting symlinks #13

Merged
merged 1 commit into from
Jun 14, 2016

Conversation

mkarg
Copy link
Collaborator

@mkarg mkarg commented May 27, 2016

When A is an existing symlink to B, then createSymbolicLink(A,C) does neither overwrite A->B by A->C (as expected in analogy to the behavior of copy(A,C)) nor does it throw an exception nor does it return A->B to indicate the failure, but it actually "silently fails", i. e. it returns A->C!

This certainly is heavily problematic, unsymmetric to what copy(File,File) and Files.createSymbolicLink(Path,Path) do, and certainly unwanted and buggy behavior.

The solution is to delete any existing target before creating the symlic, hence copying the behavior of copy(File,File).

link = Files.createSymbolicLink( link, target.toPath() );
}
if ( Files.exists( link, LinkOption.NOFOLLOW_LINKS ) )
Files.delete(link);
Copy link
Member

Choose a reason for hiding this comment

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

Hi here we usually use braces with if statement

When A is an existing symlink to B, then createSymbolicLink(A,C) does
neither overwrite A->B by A->C (as expected in analogy to the behavior
of copy(A,C)) nor does it throw an exception nor does it return A->B to
indicate the failure, but it actually "silently fails", i. e. it returns
A->C!

This certainly is heavily problematic, unsymmetric to what
copy(File,File) and Files.createSymbolicLink(Path,Path) do, and
certainly unwanted and buggy behavior.

The solution is to delete any existing target before creating the
symlic, hence copying the behavior of copy(File,File).
@mkarg mkarg force-pushed the bugfix-overwrite-symlink branch from e10fd76 to 43fb825 Compare June 14, 2016 17:58
@mkarg
Copy link
Collaborator Author

mkarg commented Jun 14, 2016

Applied Maven Code Conventions. :-)

@olamy olamy merged commit c9d5727 into codehaus-plexus:master Jun 14, 2016
@mkarg mkarg deleted the bugfix-overwrite-symlink branch June 14, 2016 22:25
@rfscholte rfscholte added this to the 3.1.0 milestone May 26, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants