mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-04 07:07:06 +00:00
exception handling during mount/unmount/reveal operations
This commit is contained in:
@@ -18,6 +18,10 @@
|
||||
<name>Cryptomator GUI</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.cryptomator</groupId>
|
||||
<artifactId>commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.cryptomator</groupId>
|
||||
<artifactId>filesystem-api</artifactId>
|
||||
|
||||
@@ -19,6 +19,7 @@ import javax.inject.Inject;
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.crypto.engine.InvalidPassphraseException;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.FrontendCreationFailedException;
|
||||
import org.cryptomator.frontend.webdav.mount.WindowsDriveLetters;
|
||||
import org.cryptomator.ui.controls.SecPasswordField;
|
||||
@@ -291,7 +292,13 @@ public class UnlockController extends AbstractFXMLViewController {
|
||||
if (vault.isUnlocked() && !mountSuccess) {
|
||||
exec.submit(vault::deactivateFrontend);
|
||||
} else if (vault.isUnlocked() && mountSuccess) {
|
||||
exec.submit(vault::reveal);
|
||||
exec.submit(() -> {
|
||||
try {
|
||||
vault.reveal();
|
||||
} catch (CommandFailedException e) {
|
||||
LOG.error("Failed to reveal mounted vault", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (mountSuccess && listener != null) {
|
||||
listener.didUnlock(this);
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.ui.model.Vault;
|
||||
import org.cryptomator.ui.util.ActiveWindowStyleSupport;
|
||||
|
||||
@@ -78,20 +79,28 @@ public class UnlockedController extends AbstractFXMLViewController {
|
||||
|
||||
@FXML
|
||||
private void didClickRevealVault(ActionEvent event) {
|
||||
exec.submit(vault::reveal);
|
||||
exec.submit(() -> {
|
||||
try {
|
||||
vault.reveal();
|
||||
} catch (CommandFailedException e) {
|
||||
Platform.runLater(() -> {
|
||||
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void didClickCloseVault(ActionEvent event) {
|
||||
exec.submit(() -> {
|
||||
// try {
|
||||
vault.unmount();
|
||||
// } catch (CommandFailedException e) {
|
||||
// Platform.runLater(() -> {
|
||||
// messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
try {
|
||||
vault.unmount();
|
||||
} catch (CommandFailedException e) {
|
||||
Platform.runLater(() -> {
|
||||
messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
|
||||
});
|
||||
return;
|
||||
}
|
||||
vault.deactivateFrontend();
|
||||
if (listener != null) {
|
||||
Platform.runLater(() -> {
|
||||
|
||||
@@ -15,10 +15,12 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.cryptomator.common.Optionals;
|
||||
import org.cryptomator.filesystem.FileSystem;
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemDelegate;
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemFactory;
|
||||
import org.cryptomator.filesystem.nio.NioFileSystem;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
import org.cryptomator.frontend.FrontendCreationFailedException;
|
||||
@@ -120,23 +122,22 @@ public class Vault implements Serializable, CryptoFileSystemDelegate {
|
||||
}
|
||||
|
||||
public Boolean mount() {
|
||||
// TODO exception handling
|
||||
Frontend frontend = filesystemFrontend.get().orElse(null);
|
||||
if (frontend == null) {
|
||||
try {
|
||||
Optionals.ifPresent(filesystemFrontend.get(), f -> {
|
||||
f.mount(getMountParams());
|
||||
});
|
||||
return true;
|
||||
} catch (CommandFailedException e) {
|
||||
return false;
|
||||
} else {
|
||||
return frontend.mount(getMountParams());
|
||||
}
|
||||
}
|
||||
|
||||
public void reveal() {
|
||||
// TODO exception handling
|
||||
filesystemFrontend.get().ifPresent(Frontend::reveal);
|
||||
public void reveal() throws CommandFailedException {
|
||||
Optionals.ifPresent(filesystemFrontend.get(), Frontend::reveal);
|
||||
}
|
||||
|
||||
public void unmount() {
|
||||
// TODO exception handling
|
||||
filesystemFrontend.get().ifPresent(Frontend::unmount);
|
||||
public void unmount() throws CommandFailedException {
|
||||
Optionals.ifPresent(filesystemFrontend.get(), Frontend::unmount);
|
||||
}
|
||||
|
||||
/* Delegate Methods */
|
||||
|
||||
Reference in New Issue
Block a user