jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Relink moved files [Find Unlinked Files part]

Open paudelritij opened this issue 3 months ago • 9 comments

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
D9481E13-FE08-4D7F-9A7D-CDFE9106959C

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.md in 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.

paudelritij avatar Sep 09 '25 03:09 paudelritij

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).

jabref-machine avatar Sep 09 '25 03:09 jabref-machine

  1. 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.
  2. org.jabref.gui.externalfiles.AutoSetFileLinksUtil#findAssociatedNotLinkedFiles was adding same link two times so I suggest to make use of set instead of list.
  3. 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)

paudelritij avatar Sep 24 '25 18:09 paudelritij

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 #xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/JabRef/jabref/issues/xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/Koppor/jabref/issues/xyz links 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.

jabref-machine avatar Sep 25 '25 15:09 jabref-machine

@trag-bot didn't find any issues in the code! ✅✨

trag-bot[bot] avatar Sep 25 '25 15:09 trag-bot[bot]

Is this PR ready for review?

calixtus avatar Oct 09 '25 21:10 calixtus

Is this PR ready for review?

I did changes could anyone please review it? Thanks.

paudelritij avatar Oct 13 '25 01:10 paudelritij

Great, we will look into it.

calixtus avatar Oct 13 '25 13:10 calixtus

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.

jabref-machine avatar Nov 19 '25 22:11 jabref-machine

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.

github-actions[bot] avatar Dec 01 '25 00:12 github-actions[bot]

This PR is being closed due to continued inactivity.

github-actions[bot] avatar Dec 12 '25 03:12 github-actions[bot]