Repository navigation
Follow symbolic links to files when isFollowingSymLinks() is set - #187
Merged
Merged
Conversation
The scanner already honours the flag when descending symlinked directories, but attributes for each entry were always read with NOFOLLOW_LINKS. ResourceFactory branches on isSymbolicLink(), so every symlinked file became a PlexusIoSymlinkResource regardless of the flag, and archives got a dangling link instead of the target's content. plexus-archiver is unaffected: AbstractArchiver hardcodes setFollowingSymLinks(false) for its file sets. Fixes #37 Co-authored-by: mirabilos <t.glaser@tarent.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #38, which cannot be rebased: it targets the
masterbranch of a fork, its author stepped away in 2021, and half its diff (aFileAttributes(Path, …)constructor) has since landed asFileAttributes(Path, boolean followLinks). Authorship is preserved with aCo-authored-bytrailer.What is left of that PR is one line.
getResources()already passes the flag toDirectoryScanner.setFollowSymlinks(), so symlinked directories are descended, butaddResources()read every entry's attributes withNOFOLLOW_LINKS. SinceResourceFactory.createResource()branches onisSymbolicLink(), a symlinked file always became aPlexusIoSymlinkResource— the flag had no effect on files.#38 resolved the entry with
toRealPath(); reading the attributes with follow instead is enough, and it leaves the entry name alone. That also answers @plamentotev's review point on the original PR without agetCanonicalPath()round trip.The flag defaults to
true, so this does change what direct plexus-io consumers get. plexus-archiver is not among them:AbstractArchiverhardcodessetFollowingSymLinks(false)for its file sets, so archiver and every Maven plugin above it are untouched. Worth a release note either way, and the draft release is already a minor bump.toRealPath()and follow-attributes both throwNoSuchFileExceptionon a dangling link.DirectoryScannerwithfollowSymlinks=truenever surfaces one, so no handling is needed —danglingSymlinkDoesNotBreakCollectionpins that down rather than leaving it to inference.This does not close codehaus-plexus/plexus-archiver#160. It is the first of three steps: plexus-archiver must stop hardcoding
falseand expose the choice perFileSet(@michael-o asked for both retention and resolution), and maven-archiver must carry the setting through to maven-source-plugin and friends.Verified:
mvn clean verify→ 58 tests, green. plexus-archiver's suite against this snapshot → 340 tests, 0 failures.Fixes #37
This change was created with AI assistance.