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

Fix issue no warning message for moving attached files #11987

Merged
merged 10 commits into from
Oct 25, 2024

Conversation

juliusalberto
Copy link
Contributor

@juliusalberto juliusalberto commented Oct 16, 2024

Supersedes PR #11904

Closes #10121

Based on the feedback given on the above PR, I have introduced these changes:

  1. In the org.jabref.logic.cleanup.MoveFilesCleanup, I collected a list of exceptions for each entry. These list of exceptions will then be stored by CleanupWorker. The CleanupAction will store every exceptions caused by IO errors, and will show it usingorg.jabref.gui.DialogService#showErrorDialogAndWait

image

Additional question: Should I create the tests as well?

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked 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 to the documentation repository.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun, check the results, commit, and push.

You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".

@Siedlerchr Siedlerchr changed the title [WIP] Fix issue no warning message [WIP] Fix issue no warning message for moving attached files Oct 16, 2024
@juliusalberto
Copy link
Contributor Author

Hi @koppor (sorry if I mentioned you in the wrong place) - do you think this is already in line with the suggestion you wrote here: #11904 (review) ?


private void showFileMoveExceptions(BibEntry entry) {
StringBuilder sb = new StringBuilder();
String title = entry.getTitle().orElse(Localization.lang("Unknown Title"));
Copy link
Member

Choose a reason for hiding this comment

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

Normally we use the citaton key. You can use org.jabref.model.entry.BibEntry#getAuthorTitleYear(int) with 40 as maxCharacters as fallbeack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I deleted the citation key part as I think it'd be difficult passing both the entry and the exceptions from org.jabref.logic.cleanup.CleanupWorker to org.jabref.gui.cleanup.CleanupAction (I will have to create a wrapper to put the entry and its corresponding exceptions)

@@ -86,4 +103,17 @@ private CleanupJob toJob(CleanupPreferences.CleanupStep action) {
throw new UnsupportedOperationException(action.name());
};
}

private void showFileMoveExceptions(BibEntry entry) {
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 too early.

Do following:

  1. Add method resetCleanUpFailures() to CleanupWorker
  2. Add field `List failures to CleanupWorker
  3. Add method getFailures() to CleanupWorker
  4. Modify org.jabref.gui.cleanup.CleanupAction#cleanup to first resetCleanUpFailures, then iterate through the entries and then show the errors

While you are in resetCleanUpFailures, move the NamedCompund generation and ending outside of the loop - the cleanup of entries is a batch and should not be split.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure why the resetCleanUpFailures() should be added to CleanupWorker when every time org.jabref.gui.cleanup.CleanupAction#doCleanup is called, the program will create a new CleanupWorker (and thus a new empty list of exceptions).

I assume that you meant to put the resetCleanupFailures in the org.jabref.gui.cleanup.CleanupAction, so the cleanupAction will store a list of exceptions.

@koppor
Copy link
Member

koppor commented Oct 18, 2024

Hi @koppor (sorry if I mentioned you in the wrong place) - do you think this is already in line with the suggestion you wrote here: #11904 (review) ?

Thank you for asking! We usually look into WIP PRs only if we are asked for. If you want to have reviews, ping us (as you did), change the PR state to "ready for review", or request review from someone using GitHubs functionality on the top right.

@koppor koppor changed the title [WIP] Fix issue no warning message for moving attached files Fix issue no warning message for moving attached files Oct 23, 2024
@koppor koppor marked this pull request as ready for review October 23, 2024 12:07
@koppor koppor added this pull request to the merge queue Oct 25, 2024
Merged via the queue into JabRef:main with commit 982aeb1 Oct 25, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning Message for Moving Attached Open Files
2 participants