Skip to content

Commit

Permalink
Try to import as regular bibtex file before trying anything else
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhard committed Jan 24, 2016
1 parent 6f9c748 commit f405cf4
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/java/net/sf/jabref/importer/ImportFormatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ public UnknownFormatImport importUnknownFormat(String filename) {
int bestResultCount = 0;
String bestFormatName = null;

// First, see if it is a BibTeX file:
try {
ParserResult pr = OpenDatabaseAction.loadDatabase(new File(filename),
Globals.prefs.getDefaultEncoding());
if ((pr.getDatabase().getEntryCount() > 0)
|| (pr.getDatabase().getStringCount() > 0)) {
pr.setFile(new File(filename));
return new UnknownFormatImport(ImportFormatReader.BIBTEX_FORMAT, pr);
}
} catch (Throwable ignore) {
}

// Cycle through all importers:
for (ImportFormat imFo : getImportFormats()) {

Expand Down Expand Up @@ -393,19 +405,6 @@ public UnknownFormatImport importUnknownFormat(String filename) {
return new UnknownFormatImport(bestFormatName, parserResult);
}

// Finally, if all else fails, see if it is a BibTeX file:
try {
ParserResult pr = OpenDatabaseAction.loadDatabase(new File(filename),
Globals.prefs.getDefaultEncoding());
if ((pr.getDatabase().getEntryCount() > 0)
|| (pr.getDatabase().getStringCount() > 0)) {
pr.setFile(new File(filename));
return new UnknownFormatImport(ImportFormatReader.BIBTEX_FORMAT, pr);
}
} catch (Throwable ex) {
return null;
}

return null;
}
}

0 comments on commit f405cf4

Please sign in to comment.