Skip to content

Commit

Permalink
Caught an error when accessing an invalid path. fixes JabRef#10548
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Martin committed Oct 20, 2024
1 parent e4649f2 commit c0510da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where DatabaseChangeDetailsView was not scrollable when reviewing external metadata changes [#11220](https://github.com/JabRef/jabref/issues/11220)
- We fixed undo/redo for text fields. [#11420](https://github.com/JabRef/jabref/issues/11420)
- We fixed an issue where clicking on a page number in the search results tab opens a wrong file in the document viewer. [#11432](https://github.com/JabRef/jabref/pull/11432)
- We fixed an issue where trying to open a library from a failed mounted directory on Mac would cause an error. [#10458](https://github.com/JabRef/jabref/issues/10548)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException;
import org.jabref.logic.shared.exception.NotASharedDatabaseException;
import org.jabref.logic.util.BackgroundTask;
import org.jabref.logic.util.Directories;
import org.jabref.logic.util.StandardFileType;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.logic.util.io.FileHistory;
Expand Down Expand Up @@ -102,11 +103,20 @@ public static void performPostOpenActions(ParserResult result, DialogService dia

@Override
public void execute() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
FileDialogConfiguration.Builder builder = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.BIBTEX_DB)
.withDefaultExtension(StandardFileType.BIBTEX_DB)
.withInitialDirectory(getInitialDirectory())
.build();
.withDefaultExtension(StandardFileType.BIBTEX_DB);

FileDialogConfiguration fileDialogConfiguration;
try {
fileDialogConfiguration = builder
.withInitialDirectory(getInitialDirectory())
.build();
} catch (IllegalArgumentException e) { // something went wrong with the directory, fallback to user directory
fileDialogConfiguration = builder
.withInitialDirectory(Directories.getUserDirectory())
.build();
}

List<Path> filesToOpen = dialogService.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration);
openFiles(new ArrayList<>(filesToOpen));
Expand Down

0 comments on commit c0510da

Please sign in to comment.