Skip to content

Commit

Permalink
While attempting to fix bug JabRef#4913, another bug was found and fi…
Browse files Browse the repository at this point in the history
…xed.

After a file was added to a library, attempting to edit the file link
in the General tab would throw an exception. It was fixed by only
allowing an edit if a file was downloaded.
  • Loading branch information
jabesse committed Apr 25, 2019
1 parent 96807fd commit 7187ded
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,19 @@ public boolean delete() {
}

public void edit() {

LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(this.linkedFile);

Optional<LinkedFile> editedFile = dialog.showAndWait();
editedFile.ifPresent(file -> {
this.linkedFile.setLink(file.getLink());
this.linkedFile.setDescription(file.getDescription());
this.linkedFile.setFileType(file.getFileType());
});
//trying to fix error when trying to edit file that is not downloaded
Optional<Path> downloadedFile = linkedFile.findIn(databaseContext, filePreferences);
if(downloadedFile.isPresent()) {

LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(this.linkedFile);

Optional<LinkedFile> editedFile = dialog.showAndWait();
editedFile.ifPresent(file -> {
this.linkedFile.setLink(file.getLink());
this.linkedFile.setDescription(file.getDescription());
this.linkedFile.setFileType(file.getFileType());
});
}
}

public void writeXMPMetadata() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public ArXivEntry(Node item) {
if (linkTitle.equals(Optional.of("pdf"))) {
pdfUrlParsed = XMLUtil.getAttributeContent(linkNode, "href").map(url -> {
try {
//#4913 bug
//#4913 bug: adding .pdf to URL did nothing; need to change the file name to not have .html
return new URL(url);
} catch (MalformedURLException e) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public void findFullTextByDOI() throws IOException {

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/cond-mat/0406246v1")), finder.findFullText(entry));
}

/* Adding .pdf didn't solve the bug.
@Test
public void givenTestBibentry_whenfindFullText_thenFindFullTextByDOIWithPDFFileTypeSuffixAdded() throws IOException {
entry.setField(FieldName.DOI, "10.1529/biophysj.104.047340");
entry.setField(FieldName.TITLE, "Pause Point Spectra in DNA Constant-Force Unzipping");
assertEquals(Optional.of(new URL("http://arxiv.org/pdf/cond-mat/0406246v1.pdf")), finder.findFullText(entry));
}

*/
@Test
public void findFullTextByEprint() throws IOException {
entry.setField("eprint", "1603.06570");
Expand Down

0 comments on commit 7187ded

Please sign in to comment.