Skip to content

Commit

Permalink
Display error message on failed deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Sep 29, 2015
1 parent 9c43d30 commit 9517c97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,20 @@ public void actionPerformed(ActionEvent e) {
}

FileListEntry entry = tableModel.getEntry(row);
Path filePath = FileUtil.expandFilename(metaData, entry.getLink()).toPath();
File file = FileUtil.expandFilename(metaData, entry.getLink());

try {
// transactional delete and unlink
if(Files.exists(filePath)) {
Files.delete(filePath);
if(file != null) {
Files.delete(file.toPath());
removeEntries();
} else {
removeEntries();
}
} catch (IOException ex) {
LOGGER.warn("File permission error while deleting: " + filePath);
JOptionPane.showMessageDialog(frame, Localization.lang("File permission error"),
Localization.lang("Cannot delete file"), JOptionPane.ERROR_MESSAGE);
LOGGER.warn("File permission error while deleting: " + file.toPath());
}
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2471,3 +2471,6 @@ This_group_contains_all_entries._It_cannot_be_edited_or_removed.=This_group_cont
Invalid_ISBN=Invalid_ISBN
MIS_Quarterly=MIS_Quarterly
Open_%0_file=Open_%0_file

Cannot_delete_file=Cannot_delete_file
File_permission_error=File_may_be_in_use_by_another_program.

0 comments on commit 9517c97

Please sign in to comment.