Relink moved files [Find Unlinked Files part]
Closes #9798
This PR relinks files, if it has been moved by user.
Steps to test
- Open `test-support\src\manual-tests\issue-9798\issue-9798.bib in JabRef
- Start "Lookup" -> "Find unlinked files"
- Start search
- File will be relinked - and following shown in the message coloumn (under import tab): File relinked to entry minimal.pdf
Mandatory checks
- [x] I own the copyright of the code submitted and I license it under the MIT license
- [x] I manually tested my changes in running JabRef (always required)
- [x] I added JUnit tests for changes (if applicable)
- [x] I added screenshots in the PR description (if change is visible to the user)
- [x] I described the change in
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user) - [x] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of [x] (done), [ ] (not done yet) or [/] (not applicable).
- I starting using existence code from AutoSetFileLinksUtil.java but found it could increase time complexity by using findAssociatedNotLinkedFiles() since it makes unnecessary call (in context of this feature) to while adding items in result (by calling findAssociatedFiles & findByBrokenLinkName), so I decided to create a separate method; and easy for testing as well.
- org.jabref.gui.externalfiles.AutoSetFileLinksUtil#findAssociatedNotLinkedFiles was adding same link two times so I suggest to make use of set instead of list.
- I had a file (a.pdf) in two places (dir/a.pdf & dir/sub-dir/a.pdf) however org.jabref.gui.externalfiles.AutoSetFileLinksUtil#findByBrokenLinkName was showing me file from sub-dir/a.pdf only so I suggest to show all related files having wantedbasename(forEach()). (one more point is that if b.txt link has been broken and findByBrokenLinkName() found file with wantedbasename to be as of b.pdf and then using code for findfirst() will add only b.pdf not b.txt which is the required one)
Your pull request needs to link an issue correctly.
To ease organizational workflows, please link this pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue:
Linking a pull request to an issue using a keyword
You can link a pull request to an issue by using a supported keyword in the pull request's description or in a commit message.
Examples
- ✅
Fixes #xyzlinks pull-request to issue. Merging the PR will close the issue. - ✅
Fixes https://github.com/JabRef/jabref/issues/xyzlinks pull-request to issue. Merging the PR will close the issue. - ✅
Fixes https://github.com/Koppor/jabref/issues/xyzlinks pull-request to issue. Merging the PR will close the issue. - ❌
Fixes [#xyz](https://github.com/JabRef/jabref/issues/xyz)links pull-request to issue. Merging the PR will NOT close the issue.
@trag-bot didn't find any issues in the code! ✅✨
Is this PR ready for review?
Is this PR ready for review?
I did changes could anyone please review it? Thanks.
Great, we will look into it.
Your code currently does not meet JabRef's code guidelines. We use OpenRewrite to ensure "modern" Java coding practices. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Source Code Tests / OpenRewrite (pull_request)" and click on it.
The issues found can be automatically fixed. Please execute the gradle task rewriteRun from the rewrite group of the Gradle Tool window in IntelliJ, then check the results, commit, and push.
Your pull request conflicts with the target branch.
Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line.
This PR is being closed due to continued inactivity.