diff --git a/src/main/java/org/cryptomator/common/mount/FuseRestartRequiredException.java b/src/main/java/org/cryptomator/common/mount/FuseRestartRequiredException.java new file mode 100644 index 000000000..1c300df89 --- /dev/null +++ b/src/main/java/org/cryptomator/common/mount/FuseRestartRequiredException.java @@ -0,0 +1,9 @@ +package org.cryptomator.common.mount; + +import org.cryptomator.integrations.mount.MountFailedException; + +public class FuseRestartRequiredException extends MountFailedException { + public FuseRestartRequiredException(String msg) { + super(msg); + } +} diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index 8da676d33..696952510 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -12,6 +12,7 @@ import org.apache.commons.lang3.SystemUtils; import org.cryptomator.common.Constants; import org.cryptomator.common.ObservableUtil; import org.cryptomator.common.mount.ActualMountService; +import org.cryptomator.common.mount.FuseRestartRequiredException; import org.cryptomator.common.mount.Mounter; import org.cryptomator.common.mount.WindowsDriveLetters; import org.cryptomator.common.settings.VaultSettings; @@ -163,7 +164,7 @@ public class Vault { && VaultModule.isProblematicFuseService(s) // && !firstUsedProblematicFuseMountService.get().equals(s)).getValue(); if(fuseRestartRequired){ - throw new MountFailedException("fuseRestartRequired"); + throw new FuseRestartRequiredException("fuseRestartRequired"); } CryptoFileSystem fs = createCryptoFileSystem(keyLoader); diff --git a/src/main/java/org/cryptomator/ui/common/FxmlFile.java b/src/main/java/org/cryptomator/ui/common/FxmlFile.java index 144b8bbb6..73a3c1817 100644 --- a/src/main/java/org/cryptomator/ui/common/FxmlFile.java +++ b/src/main/java/org/cryptomator/ui/common/FxmlFile.java @@ -44,6 +44,7 @@ public enum FxmlFile { REMOVE_VAULT("/fxml/remove_vault.fxml"), // UPDATE_REMINDER("/fxml/update_reminder.fxml"), // UNLOCK_ENTER_PASSWORD("/fxml/unlock_enter_password.fxml"), + UNLOCK_FUSE_RESTART_REQUIRED("/fxml/unlock_fuse_restart_required.fxml"), // UNLOCK_INVALID_MOUNT_POINT("/fxml/unlock_invalid_mount_point.fxml"), // UNLOCK_SELECT_MASTERKEYFILE("/fxml/unlock_select_masterkeyfile.fxml"), // UNLOCK_SUCCESS("/fxml/unlock_success.fxml"), // diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockFuseRestartRequiredController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockFuseRestartRequiredController.java new file mode 100644 index 000000000..768f41dfe --- /dev/null +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockFuseRestartRequiredController.java @@ -0,0 +1,38 @@ +package org.cryptomator.ui.unlock; + +import org.cryptomator.common.vaults.Vault; +import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.fxapp.FxApplicationWindows; +import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab; + +import javax.inject.Inject; +import javafx.fxml.FXML; +import javafx.stage.Stage; + +@UnlockScoped +public class UnlockFuseRestartRequiredController implements FxController { + + private final Stage window; + private final FxApplicationWindows appWindows; + private final Vault vault; + @Inject + UnlockFuseRestartRequiredController(@UnlockWindow Stage window, // + FxApplicationWindows appWindows, // + @UnlockWindow Vault vault) { + this.window = window; + this.appWindows = appWindows; + this.vault = vault; + } + + @FXML + public void close() { + window.close(); + } + + @FXML + public void closeAndOpenVaultOptions() { + appWindows.showVaultOptionsWindow(vault, SelectedVaultOptionsTab.MOUNT); + window.close(); + } + +} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java b/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java index f93999d21..9c3f84c6b 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java @@ -81,6 +81,13 @@ abstract class UnlockModule { return fxmlLoaders.createScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT); } + @Provides + @FxmlScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED) + @UnlockScoped + static Scene provideFuseRestartRequiredScene(@UnlockWindow FxmlLoaderFactory fxmlLoaders) { + return fxmlLoaders.createScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED); + } + // ------------------ @Binds @@ -93,4 +100,9 @@ abstract class UnlockModule { @FxControllerKey(UnlockInvalidMountPointController.class) abstract FxController bindUnlockInvalidMountPointController(UnlockInvalidMountPointController controller); + @Binds + @IntoMap + @FxControllerKey(UnlockFuseRestartRequiredController.class) + abstract FxController bindUnlockFuseRestartRequiredController(UnlockFuseRestartRequiredController controller); + } diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java b/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java index 564d57ab6..533ab0ac5 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java @@ -2,6 +2,7 @@ package org.cryptomator.ui.unlock; import com.google.common.base.Throwables; import dagger.Lazy; +import org.cryptomator.common.mount.FuseRestartRequiredException; import org.cryptomator.common.mount.IllegalMountPointException; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultState; @@ -38,17 +39,27 @@ public class UnlockWorkflow extends Task { private final VaultService vaultService; private final Lazy successScene; private final Lazy invalidMountPointScene; + private final Lazy fuseRestartRequiredScene; private final FxApplicationWindows appWindows; private final KeyLoadingStrategy keyLoadingStrategy; private final ObjectProperty illegalMountPointException; @Inject - UnlockWorkflow(@UnlockWindow Stage window, @UnlockWindow Vault vault, VaultService vaultService, @FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy successScene, @FxmlScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT) Lazy invalidMountPointScene, FxApplicationWindows appWindows, @UnlockWindow KeyLoadingStrategy keyLoadingStrategy, @UnlockWindow ObjectProperty illegalMountPointException) { + UnlockWorkflow(@UnlockWindow Stage window, // + @UnlockWindow Vault vault, // + VaultService vaultService, // + @FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy successScene, // + @FxmlScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT) Lazy invalidMountPointScene, // + @FxmlScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED) Lazy fuseRestartRequiredScene, // + FxApplicationWindows appWindows, // + @UnlockWindow KeyLoadingStrategy keyLoadingStrategy, // + @UnlockWindow ObjectProperty illegalMountPointException) { this.window = window; this.vault = vault; this.vaultService = vaultService; this.successScene = successScene; this.invalidMountPointScene = invalidMountPointScene; + this.fuseRestartRequiredScene = fuseRestartRequiredScene; this.appWindows = appWindows; this.keyLoadingStrategy = keyLoadingStrategy; this.illegalMountPointException = illegalMountPointException; @@ -85,6 +96,13 @@ public class UnlockWorkflow extends Task { }); } + private void handleFuseRestartRequiredError(FuseRestartRequiredException frre) { + Platform.runLater(() -> { + window.setScene(fuseRestartRequiredScene.get()); + window.show(); + }); + } + private void handleGenericError(Throwable e) { LOG.error("Unlock failed for technical reasons.", e); appWindows.showErrorWindow(e, window, null); @@ -115,6 +133,9 @@ public class UnlockWorkflow extends Task { Throwable throwable = super.getException(); if(throwable instanceof IllegalMountPointException impe) { handleIllegalMountPointError(impe); + } + else if (throwable instanceof FuseRestartRequiredException fRRE) { + handleFuseRestartRequiredError(fRRE); } else { handleGenericError(throwable); } diff --git a/src/main/resources/fxml/unlock_fuse_restart_required.fxml b/src/main/resources/fxml/unlock_fuse_restart_required.fxml new file mode 100644 index 000000000..b720bc196 --- /dev/null +++ b/src/main/resources/fxml/unlock_fuse_restart_required.fxml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +