Skip to content

Commit

Permalink
Fix Permissions of LaTeXintegration (#5134)
Browse files Browse the repository at this point in the history
* Differentiate Causes of Errors

* Refactor Failure Mode

* Remove unnecessary return

* Remove redundant lines
  • Loading branch information
LinusDietz authored and Siedlerchr committed Aug 18, 2019
1 parent be29e74 commit 7ec70a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.texparser;

import java.io.IOException;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -126,10 +127,19 @@ public void searchButtonClicked() {
noFilesFound.set(false);
successfulSearch.set(true);
})
.onFailure(dialogService::showErrorDialogAndWait)
.onFailure(this::handleFailure)
.executeWith(taskExecutor);
}

private void handleFailure(Exception exception) {
final boolean permissionProblem = exception instanceof IOException && exception.getCause() instanceof FileSystemException && exception.getCause().getMessage().endsWith("Operation not permitted");
if (permissionProblem) {
dialogService.showErrorDialogAndWait(String.format(Localization.lang("JabRef does not have permission to access %s"), exception.getCause().getMessage()));
} else {
dialogService.showErrorDialogAndWait(exception);
}
}

private FileNodeViewModel searchDirectory(Path directory) throws IOException {
if (directory == null || !directory.toFile().isDirectory()) {
throw new IOException(String.format("Invalid directory for searching: %s", directory));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ Open\ %0\ file=Open %0 file

Cannot\ delete\ file=Cannot delete file
File\ permission\ error=File permission error
JabRef\ does\ not\ have\ permission\ to\ access\ %s=JabRef does not have permission to access %s
Push\ to\ %0=Push to %0
Path\ to\ %0=Path to %0
Convert=Convert
Expand Down

0 comments on commit 7ec70a5

Please sign in to comment.