-
Notifications
You must be signed in to change notification settings - Fork 323
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
Fix #700. Add option to ignore broken symlinks in directories #794
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #794 +/- ##
============================================
+ Coverage 71.03% 71.73% +0.70%
- Complexity 96 100 +4
============================================
Files 7 7
Lines 580 598 +18
Branches 75 79 +4
============================================
+ Hits 412 429 +17
- Misses 121 122 +1
Partials 47 47 ☔ View full report in Codecov by Sentry. |
Thanks for the contribution! And also providing docs and test cases! |
Sounds good. Not changing the default behaviour was one of the main considerations for my solution. But to make sure, I could add a second buildData method with the old signature which just calls the new one with the default "false" new parameter. Just in case someone is using the DataBuilder api outside of maven. Is that what you had in mind, or have I overlooked something? Also, I just realised I forgot to add the new parameter in the doc comment. I'll fix that first. |
@@ -278,6 +282,15 @@ private void createParentDirectories( String filename, String user, long uid, St | |||
for (DataProducer data : producers) { | |||
data.produce(receiver); | |||
} | |||
} catch (FileNotFoundException e) { | |||
String[] arr = e.getMessage().split(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks too brittle. The very least we would need some comments on way this should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It assumes that the format of the exception message is always the same, but I couldn't figure out any other way to find out which file caused the exception.
We could of course skip the isSymbolicLink check, but then it wouldn't apply only to symlinks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK the only reliable way is to either have a custom exception that wraps the FNF (major fail), or provide the path externally.
I think in this case the only feasible option would be a custom exception that provides the path.
But again we would need to see if this requires changing any signatures. But maybe we just need to catch and re-throw in the producers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix with a custom exception, for which we have control of the exception message. Looks a bit cleaner and more robust to me at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better. But I think I would avoid re-using the message variable - and then we should be golden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/main/java/org/vafer/jdeb/ProducerFileNotFoundException.java
Outdated
Show resolved
Hide resolved
Thanks a lot! |
Add new ignoreBrokenLinks parameter to doc comment Add comment to clarify symlink checking
… exception messages Remove unused imports
…r than IOException
…rFileNotFoundException
I've never rebased a pull request before, but I think I got it right. The new commits didn't get signed though. :( |
Awesome! Thanks for the contribution. |
No problem! Thanks for your constructive feedback, I enjoyed it. There's always more to learn. |
Here's my suggested solution. I'm open for suggestions if there's a better way to pass along the ignoreBrokenLinks parameter, or any other improvements.