diff --git a/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java b/src/main/java/org/cryptomator/common/mount/ExistingHideawayException.java similarity index 55% rename from src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java rename to src/main/java/org/cryptomator/common/mount/ExistingHideawayException.java index b2a938b1c..aa720d42c 100644 --- a/src/main/java/org/cryptomator/common/mount/HideawayAlreadyExistsException.java +++ b/src/main/java/org/cryptomator/common/mount/ExistingHideawayException.java @@ -2,11 +2,11 @@ package org.cryptomator.common.mount; import java.nio.file.Path; -public class HideawayAlreadyExistsException extends IllegalMountPointException { +public class ExistingHideawayException extends IllegalMountPointException { private final Path hideaway; - public HideawayAlreadyExistsException(Path path, Path hideaway, String msg) { + public ExistingHideawayException(Path path, Path hideaway, String msg) { super(path, msg); this.hideaway = hideaway; } diff --git a/src/main/java/org/cryptomator/common/mount/MountPointCleanupFailedException.java b/src/main/java/org/cryptomator/common/mount/MountPointCleanupFailedException.java new file mode 100644 index 000000000..6246e124c --- /dev/null +++ b/src/main/java/org/cryptomator/common/mount/MountPointCleanupFailedException.java @@ -0,0 +1,10 @@ +package org.cryptomator.common.mount; + +import java.nio.file.Path; + +public class MountPointCleanupFailedException extends IllegalMountPointException { + + public MountPointCleanupFailedException(Path path) { + super(path, "Mountpoint could not be cleared: " + path.toString()); + } +} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/common/mount/MountPointCouldNotBeClearedException.java b/src/main/java/org/cryptomator/common/mount/MountPointCouldNotBeClearedException.java deleted file mode 100644 index 03150176c..000000000 --- a/src/main/java/org/cryptomator/common/mount/MountPointCouldNotBeClearedException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.cryptomator.common.mount; - -import java.nio.file.Path; - -public class MountPointCouldNotBeClearedException extends IllegalMountPointException { - - public MountPointCouldNotBeClearedException(Path path) { - super(path, "Mountpoint could not be cleared: " + path.toString()); - } -} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/common/mount/MountPointNotExistingException.java b/src/main/java/org/cryptomator/common/mount/MountPointNotExistingException.java new file mode 100644 index 000000000..bebf63ee3 --- /dev/null +++ b/src/main/java/org/cryptomator/common/mount/MountPointNotExistingException.java @@ -0,0 +1,14 @@ +package org.cryptomator.common.mount; + +import java.nio.file.Path; + +public class MountPointNotExistingException extends IllegalMountPointException { + + public MountPointNotExistingException(Path path, String msg) { + super(path, msg); + } + + public MountPointNotExistingException(Path path) { + super(path, "Mountpoint does not exist: " + path); + } +} diff --git a/src/main/java/org/cryptomator/common/mount/MountPointNotExistsException.java b/src/main/java/org/cryptomator/common/mount/MountPointNotExistsException.java deleted file mode 100644 index f1c41b0b7..000000000 --- a/src/main/java/org/cryptomator/common/mount/MountPointNotExistsException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.cryptomator.common.mount; - -import java.nio.file.Path; - -public class MountPointNotExistsException extends IllegalMountPointException { - - public MountPointNotExistsException(Path path, String msg) { - super(path, msg); - } - - public MountPointNotExistsException(Path path) { - super(path, "Mountpoint does not exist: " + path); - } -} diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index 1ee1b37cf..e7a703e43 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -26,9 +26,9 @@ 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 (" + hideaway + ") already exists for mountpoint: " + mountPoint); + throw new ExistingHideawayException(mountPoint, hideaway, "Hideaway (" + hideaway + ") already exists for mountpoint: " + mountPoint); } else if (!mpExists && !hideExists) { //neither mountpoint nor hideaway exist - throw new MountPointNotExistsException(mountPoint); + throw new MountPointNotExistingException(mountPoint); } else if (!mpExists) { //only hideaway exists checkIsDirectory(hideaway); LOG.info("Mountpoint {} seems to be not properly cleaned up. Will be fixed on unmount.", mountPoint); @@ -51,7 +51,7 @@ public final class MountWithinParentUtil { int attempts = 0; while (!Files.notExists(mountPoint)) { if (attempts >= 10) { - throw new MountPointCouldNotBeClearedException(mountPoint); + throw new MountPointCleanupFailedException(mountPoint); } Thread.sleep(1000); attempts++; diff --git a/src/main/java/org/cryptomator/common/mount/Mounter.java b/src/main/java/org/cryptomator/common/mount/Mounter.java index cb89aa50e..101524ea3 100644 --- a/src/main/java/org/cryptomator/common/mount/Mounter.java +++ b/src/main/java/org/cryptomator/common/mount/Mounter.java @@ -118,7 +118,7 @@ public class Mounter { throw new MountPointNotSupportedException(userChosenMountPoint, e.getMessage()); } else if (canMountToDir && !canMountToParent && !Files.exists(userChosenMountPoint)) { //mountpoint must exist - throw new MountPointNotExistsException(userChosenMountPoint, e.getMessage()); + throw new MountPointNotExistingException(userChosenMountPoint, e.getMessage()); } else { //TODO: add specific exception for !canMountToDir && canMountToParent && !Files.notExists(userChosenMountPoint) throw new IllegalMountPointException(userChosenMountPoint, e.getMessage()); diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java index 9144f0a74..6e11ed131 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java @@ -1,11 +1,11 @@ package org.cryptomator.ui.unlock; -import org.cryptomator.common.mount.HideawayAlreadyExistsException; +import org.cryptomator.common.mount.ExistingHideawayException; import org.cryptomator.common.mount.IllegalMountPointException; -import org.cryptomator.common.mount.MountPointCouldNotBeClearedException; +import org.cryptomator.common.mount.MountPointCleanupFailedException; import org.cryptomator.common.mount.MountPointInUseException; import org.cryptomator.common.mount.MountPointNotEmptyDirectoryException; -import org.cryptomator.common.mount.MountPointNotExistsException; +import org.cryptomator.common.mount.MountPointNotExistingException; import org.cryptomator.common.mount.MountPointNotSupportedException; import org.cryptomator.common.vaults.Vault; import org.cryptomator.ui.common.FxController; @@ -48,7 +48,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; + this.hideawayPath = exc instanceof ExistingHideawayException haeExc ? haeExc.getHideaway() : null; } @FXML @@ -79,10 +79,10 @@ public class UnlockInvalidMountPointController implements FxController { private ExceptionType getExceptionType(Throwable unlockException) { return switch (unlockException) { case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED; - case MountPointNotExistsException x -> ExceptionType.NOT_EXISTING; + case MountPointNotExistingException 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 ExistingHideawayException x -> ExceptionType.HIDEAWAY_EXISTS; + case MountPointCleanupFailedException x -> ExceptionType.COULD_NOT_BE_CLEARED; case MountPointNotEmptyDirectoryException x -> ExceptionType.NOT_EMPTY_DIRECTORY; default -> ExceptionType.GENERIC; };