diff --git a/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java b/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java index 4e47d41b61d..4e0d3010f2e 100644 --- a/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java +++ b/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java @@ -3,6 +3,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Path; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -16,6 +17,7 @@ import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.fieldeditors.LinkedFileViewModel; import org.jabref.gui.fieldeditors.LinkedFilesEditorViewModel; +import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.util.BackgroundTask; import org.jabref.logic.importer.FulltextFetchers; import org.jabref.logic.l10n.Localization; @@ -70,14 +72,20 @@ public void execute() { } } - Task>> findFullTextsTask = new Task>>() { + Task>> findFullTextsTask = new Task>>() { @Override protected Map> call() { Map> downloads = new ConcurrentHashMap<>(); int count = 0; + AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(basePanel.getBibDatabaseContext(), Globals.prefs.getFilePreferences(), Globals.prefs.getAutoLinkPreferences(), ExternalFileTypes.getInstance()); + util.linkAssociatedFiles(basePanel.getSelectedEntries(), new NamedCompound("")); + for (BibEntry entry : basePanel.getSelectedEntries()) { - FulltextFetchers fetchers = new FulltextFetchers(Globals.prefs.getImportFormatPreferences()); - downloads.put(entry, fetchers.findFullTextPDF(entry)); + List fileList = entry.getFiles(); + if (fileList.isEmpty()) { + FulltextFetchers fetchers = new FulltextFetchers(Globals.prefs.getImportFormatPreferences()); + downloads.put(entry, fetchers.findFullTextPDF(entry)); + } updateProgress(++count, basePanel.getSelectedEntries().size()); } return downloads;