diff --git a/CHANGELOG.md b/CHANGELOG.md
index 331c0d41e44..d2537c6b3a5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
### Fixed
+- We fixed to only search file links in the BIB file location directory when preferences has corresponding checkbox checked. [#5891](https://github.com/JabRef/jabref/issues/5891)
- We fixed wrong button order (Apply and Cancel) in ManageProtectedTermsDialog.
- We fixed an issue with incompatible characters at BibTeX key [#6257](https://github.com/JabRef/jabref/issues/6257)
- We fixed an issue where dash (`-`) was reported as illegal BibTeX key [#6295](https://github.com/JabRef/jabref/issues/6295)
diff --git a/src/main/java/org/jabref/gui/preferences/FileTab.fxml b/src/main/java/org/jabref/gui/preferences/FileTab.fxml
index dd1f0d4c949..ccc58a72841 100644
--- a/src/main/java/org/jabref/gui/preferences/FileTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/FileTab.fxml
@@ -43,7 +43,7 @@
-
+
diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java
index f6f56dc5bd7..20d3c85ddbb 100644
--- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java
+++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java
@@ -144,8 +144,6 @@ public List getFileDirectoriesAsPaths(FilePreferences preferences) {
// Check if we should add it as primary file dir (first in the list) or not:
if (preferences.isBibLocationAsPrimary()) {
fileDirs.add(0, parentPath);
- } else {
- fileDirs.add(parentPath);
}
});
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 16466cd3606..3f804c858d4 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -1096,7 +1096,7 @@ Web\ search=Web search
Style\ selection=Style selection
No\ valid\ style\ file\ defined=No valid style file defined
Choose\ pattern=Choose pattern
-Use\ the\ BIB\ file\ location\ as\ primary\ file\ directory=Use the BIB file location as primary file directory
+Search\ and\ store\ files\ relative\ to\ library\ file\ location=Search and store files relative to library file location
Could\ not\ run\ the\ gnuclient/emacsclient\ program.\ Make\ sure\ you\ have\ the\ emacsclient/gnuclient\ program\ installed\ and\ available\ in\ the\ PATH.=Could not run the gnuclient/emacsclient program. Make sure you have the emacsclient/gnuclient program installed and available in the PATH.
You\ must\ select\ either\ a\ valid\ style\ file,\ or\ use\ one\ of\ the\ default\ styles.=You must select either a valid style file, or use one of the default styles.
diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties
index 563b20b2f5e..a549310e395 100644
--- a/src/main/resources/l10n/JabRef_ru.properties
+++ b/src/main/resources/l10n/JabRef_ru.properties
@@ -2168,7 +2168,7 @@ This\ entry\ type\ is\ intended\ for\ sources\ such\ as\ web\ sites\ which\ are\
A\ single-volume\ work\ of\ reference\ such\ as\ an\ encyclopedia\ or\ a\ dictionary.=Неделимая работа или ссылка, как энциклопедия или словарь.
A\ technical\ report,\ research\ report,\ or\ white\ paper\ published\ by\ a\ university\ or\ some\ other\ institution.=Технический отчет, исследовательский отчет, или белая книга, выпущенная институтом или другим учреждением.
An\ entry\ set\ is\ a\ group\ of\ entries\ which\ are\ cited\ as\ a\ single\ reference\ and\ listed\ as\ a\ single\ item\ in\ the\ bibliography.=Набор записей представляет собой группу записей, которые приводятся в виде единой ссылки и перечислены в виде одного элемента в библиографии.
-Supplemental\ material\ in\ a\ "Book".\ This\ type\ is\ provided\ for\ elements\ such\ as\ prefaces,\ introductions,\ forewords,\ afterwords,\ etc.\ which\ often\ have\ a\ generic\ title\ only.=Дополнительный материал в "Книге" предназначен для таких элементов, как предисловия, введения, послесловия и т.д.
+Supplemental\ material\ in\ a\ "Book".\ This\ type\ is\ provided\ for\ elements\ such\ as\ prefaces,\ introductions,\ forewords,\ afterwords,\ etc.\ which\ often\ have\ a\ generic\ title\ only.=Дополнительный материал в "Книге" предназначен для таких элементов, как предисловия, введения, послесловия и т.д.
Supplemental\ material\ in\ a\ "Collection".=Дополнительные материалы в "Коллекции".
Supplemental\ material\ in\ a\ "Periodical".\ This\ type\ may\ be\ useful\ when\ referring\ to\ items\ such\ as\ regular\ columns,\ obituaries,\ letters\ to\ the\ editor,\ etc.\ which\ only\ have\ a\ generic\ title.=Дополнительные материалы в "Периодическом издании". Этот тип может быть полезен при обращении к таким элементам, как обычные колонки, некрологи, письма к редактору и т.д., которые имеют только общее название.
A\ thesis\ written\ for\ an\ educational\ institution\ to\ satisfy\ the\ requirements\ for\ a\ degree.=Тезис, написанный для учебного заведения с целью удовлетворения требований к степени.
diff --git a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java
index 1bcd3895338..a56080661ed 100644
--- a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java
+++ b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java
@@ -30,24 +30,31 @@ public class AutoSetFileLinksUtilTest {
private final BibDatabaseContext databaseContext = mock(BibDatabaseContext.class);
private final ExternalFileTypes externalFileTypes = mock(ExternalFileTypes.class);
private final BibEntry entry = new BibEntry(StandardEntryType.Article);
+ private Path path = null;
@BeforeEach
public void setUp(@TempDir Path folder) throws Exception {
- Path path = folder.resolve("CiteKey.pdf");
+ path = folder.resolve("CiteKey.pdf");
Files.createFile(path);
entry.setCiteKey("CiteKey");
- when(databaseContext.getFileDirectoriesAsPaths(any())).thenReturn(Collections.singletonList(path.getParent()));
when(externalFileTypes.getExternalFileTypeSelection()).thenReturn(new TreeSet<>(ExternalFileTypes.getDefaultExternalFileTypes()));
}
@Test
- public void test() throws Exception {
+ public void testFindAssociatedNotLinkedFilesSuccess() throws Exception {
// Due to mocking the externalFileType class, the file extension will not be found
-
+ when(databaseContext.getFileDirectoriesAsPaths(any())).thenReturn(Collections.singletonList(path.getParent()));
List expected = Collections.singletonList(new LinkedFile("", "CiteKey.pdf", ""));
-
AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(databaseContext, fileDirPrefs, autoLinkPrefs, externalFileTypes);
List actual = util.findAssociatedNotLinkedFiles(entry);
assertEquals(expected, actual);
}
+
+ @Test
+ public void testFindAssociatedNotLinkedFilesForEmptySearchDir() throws Exception {
+ when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(false);
+ AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(databaseContext, fileDirPrefs, autoLinkPrefs, externalFileTypes);
+ List actual = util.findAssociatedNotLinkedFiles(entry);
+ assertEquals(Collections.emptyList(), actual);
+ }
}
diff --git a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java
index 22ef8bd86e7..a237f03d6d8 100644
--- a/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java
+++ b/src/test/java/org/jabref/logic/cleanup/MoveFilesCleanupTest.java
@@ -4,8 +4,11 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import java.util.Optional;
+import org.jabref.model.FieldChange;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
@@ -32,6 +35,7 @@ class MoveFilesCleanupTest {
private MoveFilesCleanup cleanup;
private BibEntry entry;
private FilePreferences filePreferences;
+ private BibDatabaseContext databaseContext;
@BeforeEach
void setUp(@TempDir Path bibFolder) throws IOException {
@@ -47,7 +51,7 @@ void setUp(@TempDir Path bibFolder) throws IOException {
MetaData metaData = new MetaData();
metaData.setDefaultFileDirectory(defaultFileFolder.toAbsolutePath().toString());
- BibDatabaseContext databaseContext = new BibDatabaseContext(new BibDatabase(), metaData);
+ databaseContext = new BibDatabaseContext(new BibDatabase(), metaData);
Files.createFile(bibFolder.resolve("test.bib"));
databaseContext.setDatabasePath(bibFolder.resolve("test.bib"));
@@ -119,4 +123,12 @@ void movesFileWithSubdirectoryPattern() throws Exception {
assertFalse(Files.exists(fileBefore));
assertTrue(Files.exists(fileAfter));
}
+
+ @Test
+ void movesFileWithNoDirectory() throws Exception {
+ databaseContext.setMetaData(new MetaData());
+ when(filePreferences.getFileDirPattern()).thenReturn("");
+ List changes = cleanup.cleanup(entry);
+ assertEquals(Collections.emptyList(), changes);
+ }
}
diff --git a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java
index 1401fcf08b9..aa7b3fa5723 100644
--- a/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java
+++ b/src/test/java/org/jabref/logic/integrity/IntegrityCheckTest.java
@@ -36,6 +36,7 @@
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
/**
* This class tests the Integrity Checker as a whole.
@@ -177,8 +178,10 @@ private void assertWrong(BibDatabaseContext context) {
}
private void assertCorrect(BibDatabaseContext context) {
+ FilePreferences filePreferencesMock = mock(FilePreferences.class);
+ when(filePreferencesMock.isBibLocationAsPrimary()).thenReturn(true);
List messages = new IntegrityCheck(context,
- mock(FilePreferences.class),
+ filePreferencesMock,
createBibtexKeyPatternPreferences(),
JournalAbbreviationLoader.loadBuiltInRepository(), false
).check();