From 900e431bcb40146523cefda41aa22da3aa44ef4e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 23 Nov 2019 12:36:58 +0100 Subject: [PATCH] Auto file finder follows symbolic links --- CHANGELOG.md | 1 + .../java/org/jabref/logic/util/io/CiteKeyBasedFileFinder.java | 3 ++- .../java/org/jabref/logic/util/io/RegExpBasedFileFinder.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51879c2a3b8..4a6d90b4524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed various issues (including [#5263](https://github.com/JabRef/jabref/issues/5263)) related to copying entries to the clipboard - We fixed some display errors in the preferences dialog and replaced some of the controls [#5033](https://github.com/JabRef/jabref/pull/5033) [#5047](https://github.com/JabRef/jabref/pull/5047) [#5062](https://github.com/JabRef/jabref/pull/5062) [#5141](https://github.com/JabRef/jabref/pull/5141) [#5185](https://github.com/JabRef/jabref/pull/5185) [#5265](https://github.com/JabRef/jabref/pull/5265) [#5315](https://github.com/JabRef/jabref/pull/5315) [#5360](https://github.com/JabRef/jabref/pull/5360) - We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447) +- The "Automatically set file links" feature now follows symbolic links. [#5664](https://github.com/JabRef/jabref/issues/5664) - After successful import of one or multiple bib entries the main table scrolls to the first imported entry [#5383](https://github.com/JabRef/jabref/issues/5383) - We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) - We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463) diff --git a/src/main/java/org/jabref/logic/util/io/CiteKeyBasedFileFinder.java b/src/main/java/org/jabref/logic/util/io/CiteKeyBasedFileFinder.java index 72454b19a7a..85a90498e12 100644 --- a/src/main/java/org/jabref/logic/util/io/CiteKeyBasedFileFinder.java +++ b/src/main/java/org/jabref/logic/util/io/CiteKeyBasedFileFinder.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.UncheckedIOException; +import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; @@ -87,7 +88,7 @@ private Set findFilesByExtension(List directories, List exte Set result = new HashSet<>(); for (Path directory : directories) { if (Files.exists(directory)) { - try (Stream pathStream = Files.find(directory, Integer.MAX_VALUE, isFileWithCorrectExtension)) { + try (Stream pathStream = Files.find(directory, Integer.MAX_VALUE, isFileWithCorrectExtension, FileVisitOption.FOLLOW_LINKS)) { result.addAll(pathStream.collect(Collectors.toSet())); } catch (UncheckedIOException e) { throw new IOException("Problem in finding files", e); diff --git a/src/main/java/org/jabref/logic/util/io/RegExpBasedFileFinder.java b/src/main/java/org/jabref/logic/util/io/RegExpBasedFileFinder.java index 667a2855661..627a00edec9 100644 --- a/src/main/java/org/jabref/logic/util/io/RegExpBasedFileFinder.java +++ b/src/main/java/org/jabref/logic/util/io/RegExpBasedFileFinder.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; +import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -201,7 +202,7 @@ private List findFile(final BibEntry entry, final Path directory, final St } private List collectFilesWithMatcher(Path actualDirectory, BiPredicate matcher) { - try (Stream pathStream = Files.find(actualDirectory, 1, matcher)) { + try (Stream pathStream = Files.find(actualDirectory, 1, matcher, FileVisitOption.FOLLOW_LINKS)) { return pathStream.collect(Collectors.toList()); } catch (UncheckedIOException | IOException ioe) { return Collections.emptyList();