-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Improve things arround change detection #5770
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
Changes from all commits
eea5bf4
873109d
5730104
52471b5
87cd599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package org.jabref.logic.importer; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
tobiasdiez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
|
@@ -29,31 +31,26 @@ private OpenDatabase() { | |
* | ||
* @param name Name of the BIB-file to open | ||
* @return ParserResult which never is null | ||
* @deprecated use {@link #loadDatabase(Path, ImportFormatPreferences, FileUpdateMonitor)} instead | ||
*/ | ||
@Deprecated | ||
public static ParserResult loadDatabase(String name, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) { | ||
File file = new File(name); | ||
LOGGER.info("Opening: " + name); | ||
LOGGER.debug("Opening: " + name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't "Opening {}", name work? - I think, this is the style one does in Java, because otherwise the debug string is always calculated even if the statement is not set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that micro optimization? |
||
Path file = Paths.get(name); | ||
|
||
if (!file.exists()) { | ||
if (!Files.exists(file)) { | ||
ParserResult pr = ParserResult.fromErrorMessage(Localization.lang("File not found")); | ||
pr.setFile(file); | ||
pr.setFile(file.toFile()); | ||
|
||
LOGGER.error(Localization.lang("Error") + ": " + Localization.lang("File not found")); | ||
return pr; | ||
} | ||
|
||
try { | ||
ParserResult pr = OpenDatabase.loadDatabase(file, importFormatPreferences, fileMonitor); | ||
pr.setFile(file); | ||
if (pr.hasWarnings()) { | ||
for (String aWarn : pr.warnings()) { | ||
LOGGER.warn(aWarn); | ||
} | ||
} | ||
return pr; | ||
return OpenDatabase.loadDatabase(file, importFormatPreferences, fileMonitor); | ||
} catch (IOException ex) { | ||
ParserResult pr = ParserResult.fromError(ex); | ||
pr.setFile(file); | ||
pr.setFile(file.toFile()); | ||
LOGGER.error("Problem opening .bib-file", ex); | ||
return pr; | ||
} | ||
|
@@ -62,9 +59,9 @@ public static ParserResult loadDatabase(String name, ImportFormatPreferences imp | |
/** | ||
* Opens a new database. | ||
*/ | ||
public static ParserResult loadDatabase(File fileToOpen, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) | ||
public static ParserResult loadDatabase(Path fileToOpen, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) | ||
throws IOException { | ||
ParserResult result = new BibtexImporter(importFormatPreferences, fileMonitor).importDatabase(fileToOpen.toPath(), | ||
ParserResult result = new BibtexImporter(importFormatPreferences, fileMonitor).importDatabase(fileToOpen, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change it from path to file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This question is asked, because java.nio.Path should be preferred over java.io.File. We are aware in the code that this causes some conversion issues, however, I think, we should keep to move forward here. (Is this article still the best google result? --> https://jaxenter.de/java-nio-file-zeitgemases-arbeiten-mit-dateien-2581) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually converted it to a Path, the method now accepts a Path variable and not a File |
||
importFormatPreferences.getEncoding()); | ||
|
||
if (importFormatPreferences.isKeywordSyncEnabled()) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.