diff --git a/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java b/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java index 57f255b2e..b2a938b1c 100644 --- a/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java +++ b/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java @@ -4,7 +4,14 @@ import java.nio.file.Path; public class HideawayAlreadyExistsException extends IllegalMountPointException { - public HideawayAlreadyExistsException(Path path, String msg) { + private final Path hideaway; + + public HideawayAlreadyExistsException(Path path, Path hideaway, String msg) { super(path, msg); + this.hideaway = hideaway; + } + + public Path getHideaway() { + return hideaway; } } \ No newline at end of file diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index 4c829d68d..1ee1b37cf 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -26,7 +26,7 @@ public final class MountWithinParentUtil { //TODO: possible improvement by just deleting an _empty_ hideaway if (mpExists && hideExists) { //both resources exist (whatever type) - throw new HideawayAlreadyExistsException(mountPoint, "Hideaway (" + hideaway + ") already exists for mountpoint: " + mountPoint); + throw new HideawayAlreadyExistsException(mountPoint, hideaway, "Hideaway (" + hideaway + ") already exists for mountpoint: " + mountPoint); } else if (!mpExists && !hideExists) { //neither mountpoint nor hideaway exist throw new MountPointNotExistsException(mountPoint); } else if (!mpExists) { //only hideaway exists diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java index 509df30dd..37ae85b9b 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java @@ -1,5 +1,6 @@ package org.cryptomator.ui.unlock; +import org.cryptomator.common.mount.HideawayAlreadyExistsException; import org.cryptomator.common.mount.IllegalMountPointException; import org.cryptomator.common.mount.MountPointCouldNotBeClearedException; import org.cryptomator.common.mount.MountPointInUseException; @@ -31,6 +32,7 @@ public class UnlockInvalidMountPointController implements FxController { private final ExceptionType exceptionType; private final Path exceptionPath; private final String exceptionMessage; + private final Path hideawayPath; public FormattedLabel dialogDescription; @@ -45,6 +47,7 @@ public class UnlockInvalidMountPointController implements FxController { this.exceptionType = getExceptionType(exc); this.exceptionPath = exc.getMountpoint(); this.exceptionMessage = exc.getMessage(); + this.hideawayPath = exc instanceof HideawayAlreadyExistsException haeExc ? haeExc.getHideaway() : null; } @FXML @@ -52,6 +55,7 @@ public class UnlockInvalidMountPointController implements FxController { dialogDescription.setFormat(resourceBundle.getString(exceptionType.translationKey)); dialogDescription.setArg1(exceptionPath); dialogDescription.setArg2(exceptionMessage); + dialogDescription.setArg3(hideawayPath); } @FXML @@ -76,6 +80,7 @@ public class UnlockInvalidMountPointController implements FxController { case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED; case MountPointNotExistsException x -> ExceptionType.NOT_EXISTING; case MountPointInUseException x -> ExceptionType.IN_USE; + case HideawayAlreadyExistsException x -> ExceptionType.HIDEAWAY_EXISTS; case MountPointCouldNotBeClearedException x -> ExceptionType.COULD_NOT_BE_CLEARED; case MountPointNotEmptyDirectoryException x -> ExceptionType.NOT_EMPTY_DIRECTORY; default -> ExceptionType.GENERIC; @@ -87,6 +92,7 @@ public class UnlockInvalidMountPointController implements FxController { NOT_SUPPORTED("unlock.error.customPath.description.notSupported", ButtonAction.SHOW_PREFERENCES), NOT_EXISTING("unlock.error.customPath.description.notExists", ButtonAction.SHOW_VAULT_OPTIONS), IN_USE("unlock.error.customPath.description.inUse", ButtonAction.SHOW_VAULT_OPTIONS), + HIDEAWAY_EXISTS("unlock.error.customPath.description.hideawayExists", ButtonAction.SHOW_VAULT_OPTIONS), COULD_NOT_BE_CLEARED("unlock.error.customPath.description.couldNotBeCleaned", ButtonAction.SHOW_VAULT_OPTIONS), NOT_EMPTY_DIRECTORY("unlock.error.customPath.description.notEmptyDir", ButtonAction.SHOW_VAULT_OPTIONS), GENERIC("unlock.error.customPath.description.generic", ButtonAction.SHOW_PREFERENCES); @@ -102,6 +108,7 @@ public class UnlockInvalidMountPointController implements FxController { private enum ButtonAction { + //TODO Add option to show filesystem, e.g. for ExceptionType.HIDEAWAY_EXISTS SHOW_PREFERENCES, SHOW_VAULT_OPTIONS; diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index 730609137..d0d770329 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -131,6 +131,7 @@ unlock.error.customPath.message=Unable to mount vault to custom path unlock.error.customPath.description.notSupported=If you wish to keep using the custom path, please go to the preferences and select a volume type that supports it. Otherwise, go to the vault options and choose a supported mount point. unlock.error.customPath.description.notExists=The custom mount path does not exist. Either create it in your local filesystem or change it in the vault options. unlock.error.customPath.description.inUse=Drive letter "%s" is already in use. +unlock.error.customPath.description.hideawayExists=The folder "%3$s", which is used to preserve folder properties set by you, has not been automatically cleaned up since your last mount to "%1$s". Please delete it manually and restore any properties to the original mount path if you set any. unlock.error.customPath.description.couldNotBeCleaned=Your vault could not be mounted to the path "%s". Please try again or choose a different path. unlock.error.customPath.description.notEmptyDir=The custom mount path "%s" is not an empty folder. Please choose an empty folder and try again. unlock.error.customPath.description.generic=You have selected a custom mount path for this vault, but using it failed with the message: %2$s