You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Kristian Rosenvold <kr...@gmail.com> on 2014/09/26 22:26:27 UTC

The mess that is symlinks....

I now have fully working implementations of zip/tar with symlink
support. Unfortunately there is a slight mess in current symlink
support that needs to be sorted out. Prior to java7, we were only able
to (unreliably) detect that a directory was a symlink. Detecting
symlink files was impossible. With java7 plus we can detect and handle
all kinds of symlinks.

I created a test in m-s-u that illustrates the problem, the test
structure can be found here:

https://svn.apache.org/repos/asf/maven/shared/trunk/maven-shared-utils/src/test/resources/symlinks/

Now there is a unit test within the same project that looks like this:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: The mess that is symlinks....

Posted by Kristian Rosenvold <kr...@gmail.com>.
    @Test
    public void followSymlinks(){
        DirectoryScanner ds = new DirectoryScanner();
        ds.setBasedir( new File("src/test/resources/symlinks/src/") );
        ds.setFollowSymlinks( false );
        ds.scan();
        List<String> included = Arrays.asList( ds.getIncludedFiles() );
        System.out.println( "includedFiles(nosymlinks) = " + included );
        ds.setFollowSymlinks( true );
        ds.scan();
        included = Arrays.asList( ds.getIncludedFiles() );
        System.out.println( "includedFiles(symlinks  ) = " + included );
    }

Which produces the following output:

includedFiles(nosymlinks) = [aRegularDir/aRegularFile.txt, fileR.txt,
fileW.txt, fileX.txt, symLinkToFileOnTheOutside, symR, symW, symX,
targetDir/targetFile.txt]
includedFiles(symlinks  ) = [aRegularDir/aRegularFile.txt, fileR.txt,
fileW.txt, fileX.txt, symDir/targetFile.txt,
symLinkToDirOnTheOutside/FileInDirOnTheOutside.txt,
symLinkToFileOnTheOutside, symR, symW, symX, targetDir/targetFile.txt]


Now my proposal is that the "symlinks" output stays the way it
currently is, but that we include the actual symlink elements in the
"nosymlink" parts; without traversing any further across the symlink.
So "nosymlinks" would include "symDir", "symLinkToDirOnTheOutside" and
"symLinkToFileOnTheOutside" as well as the currently included symR,
symW and symX.

It seems to me like this is the only consistent way to handle this
issue. It might break some compatibility, but the current solution is
just total "crap", so we need to find a better one....



Kristian


2014-09-26 22:26 GMT+02:00 Kristian Rosenvold <kr...@gmail.com>:
> I now have fully working implementations of zip/tar with symlink
> support. Unfortunately there is a slight mess in current symlink
> support that needs to be sorted out. Prior to java7, we were only able
> to (unreliably) detect that a directory was a symlink. Detecting
> symlink files was impossible. With java7 plus we can detect and handle
> all kinds of symlinks.
>
> I created a test in m-s-u that illustrates the problem, the test
> structure can be found here:
>
> https://svn.apache.org/repos/asf/maven/shared/trunk/maven-shared-utils/src/test/resources/symlinks/
>
> Now there is a unit test within the same project that looks like this:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: The mess that is symlinks....

Posted by Kristian Rosenvold <kr...@gmail.com>.
I have created

http://jira.codehaus.org/browse/MSHARED-350
http://jira.codehaus.org/browse/PLXUTILS-165

to deal with this. I'm convinced there is only one right thing (tm) to
do, so I will do that :)

Kristian


2014-09-26 22:26 GMT+02:00 Kristian Rosenvold <kr...@gmail.com>:
> I now have fully working implementations of zip/tar with symlink
> support. Unfortunately there is a slight mess in current symlink
> support that needs to be sorted out. Prior to java7, we were only able
> to (unreliably) detect that a directory was a symlink. Detecting
> symlink files was impossible. With java7 plus we can detect and handle
> all kinds of symlinks.
>
> I created a test in m-s-u that illustrates the problem, the test
> structure can be found here:
>
> https://svn.apache.org/repos/asf/maven/shared/trunk/maven-shared-utils/src/test/resources/symlinks/
>
> Now there is a unit test within the same project that looks like this:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org