diff --git a/CHANGELOG.md b/CHANGELOG.md index b60dc4ae172..dc086497a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - After assigning an entry to a group, the item count is now properly colored to reflect the new membership of the entry. [#3112](https://github.com/JabRef/jabref/issues/3112) - The group panel is now properly updated when switching between libraries (or when closing/opening one). [#3142](https://github.com/JabRef/jabref/issues/3142) - We fixed an error where the number of matched entries shown in the group pane was not updated correctly. [#4441](https://github.com/JabRef/jabref/issues/4441) +- We fixed an error where the wrong file is renamed and linked when using the "Copy, rename and link" action. [#5653](https://github.com/JabRef/jabref/issues/5653) - We fixed a "null" error when writing XMP metadata. [#5449](https://github.com/JabRef/jabref/issues/5449) - We fixed an issue where empty keywords lead to a strange display of automatic keyword groups. [#5333](https://github.com/JabRef/jabref/issues/5333) - We fixed an error where the default color of a new group was white instead of dark gray. [#4868](https://github.com/JabRef/jabref/issues/4868) diff --git a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java index ab2b1e9c819..657ece362e5 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java +++ b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java @@ -1,6 +1,7 @@ package org.jabref.gui.externalfiles; import java.nio.file.Path; +import java.util.Collections; import java.util.List; import java.util.Optional; @@ -36,7 +37,7 @@ public Optional copyFileToFileDir(Path file) { if (firstExistingFileDir.isPresent()) { Path targetFile = firstExistingFileDir.get().resolve(file.getFileName()); if (FileUtil.copyFile(file, targetFile, false)) { - return Optional.ofNullable(targetFile); + return Optional.of(targetFile); } } return Optional.empty(); @@ -71,7 +72,7 @@ public void moveFilesToFileDirAndAddToEntry(BibEntry entry, List files) { public void copyFilesToFileDirAndAddToEntry(BibEntry entry, List files) { for (Path file : files) { copyFileToFileDir(file) - .ifPresent(copiedFile -> addFilesToEntry(entry, files)); + .ifPresent(copiedFile -> addFilesToEntry(entry, Collections.singletonList(copiedFile))); } renameLinkedFilesToPattern(entry); }