@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 <[email protected]>:
> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to