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

Support following symbolic links to files #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCac
@Nonnull Map<Integer, String> groupCache )
throws IOException
{
this( file.toPath(), userCache, groupCache );
}

Path path = file.toPath();
public FileAttributes( @Nonnull Path path, @Nonnull Map<Integer, String> userCache,
@Nonnull Map<Integer, String> groupCache )
throws IOException
{
Set<String> views = path.getFileSystem().supportedFileAttributeViews();
String names;
if ( views.contains( "unix" ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -158,8 +159,13 @@ private void addResources( List<PlexusIoResource> result, String[] resources )
{
String sourceDir = name.replace( '\\', '/' );
File f = new File( dir, sourceDir );
Path p = f.toPath();
if ( isFollowingSymLinks() )
Copy link
Member

Choose a reason for hiding this comment

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

This is true by default isFollowingSymLinks. I'm a bit concerned that this change would change the behavior of existing applications. I know the existing behavior is odd, but it was existing for quite some time and maybe there are applications that depend on it. Do you think adding additional flag would made sense? In general I hate fix bug kind of flags, but this code was here for quite some time and maybe there is code out there depending on PlexusIoFileResourceCollection not following symlinks by default.

{
p = p.toRealPath();
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 f.getCanonicalPath() would do the same without introducing Path.

}

FileAttributes fattrs = new FileAttributes( f, cache1, cache2 );
FileAttributes fattrs = new FileAttributes( p, cache1, cache2 );
PlexusIoResourceAttributes attrs = mergeAttributes( fattrs, fattrs.isDirectory() );

String remappedName = getName( name );
Expand Down