renamed fuse-specific exception to be more generic

This commit is contained in:
Sebastian Stenzel
2023-12-21 10:05:22 +01:00
parent a0fcb63a1a
commit c86ee679a9
11 changed files with 50 additions and 49 deletions

View File

@@ -0,0 +1,14 @@
package org.cryptomator.common.mount;
import org.cryptomator.integrations.mount.MountFailedException;
/**
* Thrown by {@link Mounter} to indicate that the selected mount service can not be used
* due to incompatibilities with a different mount service that is already in use.
*/
public class ConflictingMountServiceException extends MountFailedException {
public ConflictingMountServiceException(String msg) {
super(msg);
}
}

View File

@@ -1,10 +0,0 @@
package org.cryptomator.common.mount;
import org.cryptomator.integrations.mount.MountFailedException;
public class FuseRestartRequiredException extends MountFailedException {
public FuseRestartRequiredException(String msg) {
super(msg);
}
}

View File

@@ -158,8 +158,8 @@ public class Mounter {
var mountService = mountProviders.stream().filter(s -> s.getClass().getName().equals(vaultSettings.mountService.getValue())).findFirst().orElse(defaultMountService.getValue());
if (isConflictingMountService(mountService)) {
// TODO: neither message displayed in UI nor exception is specific to FUSE, so rename this class
throw new FuseRestartRequiredException("Failed to mount the specified mount service.");
var msg = STR."\{mountService.getClass()} unavailable due to conflict with either of \{CONFLICTING_MOUNT_SERVICES.get(mountService.getClass().getName())}";
throw new ConflictingMountServiceException(msg);
}
usedMountServices.add(mountService);

View File

@@ -45,7 +45,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_REQUIRES_RESTART("/fxml/unlock_requires_restart.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"), //

View File

@@ -82,10 +82,10 @@ abstract class UnlockModule {
}
@Provides
@FxmlScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED)
@FxmlScene(FxmlFile.UNLOCK_REQUIRES_RESTART)
@UnlockScoped
static Scene provideFuseRestartRequiredScene(@UnlockWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED);
static Scene provideRestartRequiredScene(@UnlockWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.UNLOCK_REQUIRES_RESTART);
}
// ------------------
@@ -102,7 +102,7 @@ abstract class UnlockModule {
@Binds
@IntoMap
@FxControllerKey(UnlockFuseRestartRequiredController.class)
abstract FxController bindUnlockFuseRestartRequiredController(UnlockFuseRestartRequiredController controller);
@FxControllerKey(UnlockRequiresRestartController.class)
abstract FxController bindUnlockRequiresRestartController(UnlockRequiresRestartController controller);
}

View File

@@ -11,7 +11,7 @@ import javafx.stage.Stage;
import java.util.ResourceBundle;
@UnlockScoped
public class UnlockFuseRestartRequiredController implements FxController {
public class UnlockRequiresRestartController implements FxController {
private final Stage window;
private final ResourceBundle resourceBundle;
@@ -19,10 +19,10 @@ public class UnlockFuseRestartRequiredController implements FxController {
private final Vault vault;
@Inject
UnlockFuseRestartRequiredController(@UnlockWindow Stage window, //
ResourceBundle resourceBundle, //
FxApplicationWindows appWindows, //
@UnlockWindow Vault vault) {
UnlockRequiresRestartController(@UnlockWindow Stage window, //
ResourceBundle resourceBundle, //
FxApplicationWindows appWindows, //
@UnlockWindow Vault vault) {
this.window = window;
this.resourceBundle = resourceBundle;
this.appWindows = appWindows;

View File

@@ -1,7 +1,7 @@
package org.cryptomator.ui.unlock;
import dagger.Lazy;
import org.cryptomator.common.mount.FuseRestartRequiredException;
import org.cryptomator.common.mount.ConflictingMountServiceException;
import org.cryptomator.common.mount.IllegalMountPointException;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultState;
@@ -38,7 +38,7 @@ public class UnlockWorkflow extends Task<Void> {
private final VaultService vaultService;
private final Lazy<Scene> successScene;
private final Lazy<Scene> invalidMountPointScene;
private final Lazy<Scene> fuseRestartRequiredScene;
private final Lazy<Scene> restartRequiredScene;
private final FxApplicationWindows appWindows;
private final KeyLoadingStrategy keyLoadingStrategy;
private final ObjectProperty<IllegalMountPointException> illegalMountPointException;
@@ -49,7 +49,7 @@ public class UnlockWorkflow extends Task<Void> {
VaultService vaultService, //
@FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy<Scene> successScene, //
@FxmlScene(FxmlFile.UNLOCK_INVALID_MOUNT_POINT) Lazy<Scene> invalidMountPointScene, //
@FxmlScene(FxmlFile.UNLOCK_FUSE_RESTART_REQUIRED) Lazy<Scene> fuseRestartRequiredScene, //
@FxmlScene(FxmlFile.UNLOCK_REQUIRES_RESTART) Lazy<Scene> restartRequiredScene, //
FxApplicationWindows appWindows, //
@UnlockWindow KeyLoadingStrategy keyLoadingStrategy, //
@UnlockWindow ObjectProperty<IllegalMountPointException> illegalMountPointException) {
@@ -58,7 +58,7 @@ public class UnlockWorkflow extends Task<Void> {
this.vaultService = vaultService;
this.successScene = successScene;
this.invalidMountPointScene = invalidMountPointScene;
this.fuseRestartRequiredScene = fuseRestartRequiredScene;
this.restartRequiredScene = restartRequiredScene;
this.appWindows = appWindows;
this.keyLoadingStrategy = keyLoadingStrategy;
this.illegalMountPointException = illegalMountPointException;
@@ -87,9 +87,9 @@ public class UnlockWorkflow extends Task<Void> {
});
}
private void handleFuseRestartRequiredError() {
private void handleConflictingMountServiceException() {
Platform.runLater(() -> {
window.setScene(fuseRestartRequiredScene.get());
window.setScene(restartRequiredScene.get());
window.show();
});
}
@@ -122,12 +122,10 @@ public class UnlockWorkflow extends Task<Void> {
protected void failed() {
LOG.info("Unlock of '{}' failed.", vault.getDisplayName());
Throwable throwable = super.getException();
if(throwable instanceof IllegalMountPointException impe) {
handleIllegalMountPointError(impe);
} else if (throwable instanceof FuseRestartRequiredException _) {
handleFuseRestartRequiredError();
} else {
handleGenericError(throwable);
switch (throwable) {
case IllegalMountPointException e -> handleIllegalMountPointError(e);
case ConflictingMountServiceException _ -> handleConflictingMountServiceException();
default -> handleGenericError(throwable);
}
vault.stateProperty().transition(VaultState.Value.PROCESSING, VaultState.Value.LOCKED);
}

View File

@@ -15,7 +15,6 @@ import org.cryptomator.ui.preferences.SelectedPreferencesTab;
import org.cryptomator.ui.preferences.VolumePreferencesController;
import javax.inject.Inject;
import javax.inject.Named;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ObservableValue;
@@ -59,7 +58,7 @@ public class MountOptionsController implements FxController {
private final List<MountService> mountProviders;
private final ObservableValue<MountService> defaultMountService;
private final ObservableValue<MountService> selectedMountService;
private final ObservableValue<Boolean> fuseRestartRequired;
private final ObservableValue<Boolean> selectedMountServiceRequiresRestart;
private final ObservableValue<Boolean> loopbackPortChangeable;
@@ -98,7 +97,7 @@ public class MountOptionsController implements FxController {
this.mountProviders = mountProviders;
this.defaultMountService = defaultMountService;
this.selectedMountService = Bindings.createObjectBinding(this::reselectMountService, defaultMountService, vaultSettings.mountService);
this.fuseRestartRequired = selectedMountService.map(mounter::isConflictingMountService);
this.selectedMountServiceRequiresRestart = selectedMountService.map(mounter::isConflictingMountService);
this.defaultMountFlags = selectedMountService.map(s -> {
if (s.hasCapability(MountCapability.MOUNT_FLAGS)) {
@@ -362,12 +361,12 @@ public class MountOptionsController implements FxController {
return directoryPath.getValue();
}
public ObservableValue<Boolean> fuseRestartRequiredProperty() {
return fuseRestartRequired;
public ObservableValue<Boolean> selectedMountServiceRequiresRestartProperty() {
return selectedMountServiceRequiresRestart;
}
public boolean getFuseRestartRequired() {
return fuseRestartRequired.getValue();
public boolean getSelectedMountServiceRequiresRestart() {
return selectedMountServiceRequiresRestart.getValue();
}
public ObservableValue<Boolean> loopbackPortChangeableProperty() {