mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-19 03:01:27 +00:00
Cleaned up merge
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ExistingHideawayException extends IllegalMountPointException {
|
||||
|
||||
private final Path hideaway;
|
||||
|
||||
public ExistingHideawayException(Path path, Path hideaway, String msg) {
|
||||
super(path, msg);
|
||||
this.hideaway = hideaway;
|
||||
}
|
||||
|
||||
public Path getHideaway() {
|
||||
return hideaway;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class HideawayNotDirectoryException extends IllegalMountPointException {
|
||||
|
||||
private final Path hideaway;
|
||||
|
||||
public HideawayNotDirectoryException(Path path, Path hideaway) {
|
||||
super(path, "Existing hideaway (" + hideaway.toString() + ") for mountpoint is not a directory: " + path.toString());
|
||||
this.hideaway = hideaway;
|
||||
}
|
||||
|
||||
public Path getHideaway() {
|
||||
return hideaway;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.NotDirectoryException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -28,8 +27,6 @@ public final class MountWithinParentUtil {
|
||||
var mpExists = removeResidualJunction(mountPoint); //Handle junction as not existing
|
||||
var hideExists = Files.exists(hideaway, LinkOption.NOFOLLOW_LINKS);
|
||||
|
||||
//TODO: possible improvement by just deleting an _empty_ hideaway
|
||||
//TODO: Remove "ExistingHideawayException"
|
||||
if (!mpExists && !hideExists) { //neither mountpoint nor hideaway exist
|
||||
throw new MountPointNotExistingException(mountPoint);
|
||||
} else if (!mpExists) { //only hideaway exists
|
||||
@@ -45,7 +42,7 @@ public final class MountWithinParentUtil {
|
||||
} else { //mountpoint exists...
|
||||
try {
|
||||
if (hideExists) { //... with hideaway
|
||||
removeResidualHideaway(hideaway);
|
||||
removeResidualHideaway(mountPoint, hideaway);
|
||||
}
|
||||
|
||||
//... (now) without hideaway
|
||||
@@ -73,8 +70,7 @@ public final class MountWithinParentUtil {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Remove MountPointPreparationException
|
||||
private static boolean removeResidualJunction(Path path) throws MountPointPreparationException {
|
||||
private static boolean removeResidualJunction(Path path) {
|
||||
try {
|
||||
if (Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isOther()) {
|
||||
LOG.info("Mountpoint \"{}\" is still a junction. Deleting it.", path);
|
||||
@@ -85,14 +81,13 @@ public final class MountWithinParentUtil {
|
||||
} catch (NoSuchFileException e) {
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
throw new MountPointPreparationException(e);
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Remove MountPointPreparationException
|
||||
private static void removeResidualHideaway(Path hideaway) throws IOException {
|
||||
private static void removeResidualHideaway(Path mountPoint, Path hideaway) throws IOException {
|
||||
if (!Files.isDirectory(hideaway, LinkOption.NOFOLLOW_LINKS)) {
|
||||
throw new MountPointPreparationException(new NotDirectoryException(hideaway.toString()));
|
||||
throw new HideawayNotDirectoryException(mountPoint, hideaway);
|
||||
}
|
||||
Files.delete(hideaway); //Fails if not empty
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.cryptomator.ui.unlock;
|
||||
|
||||
import org.cryptomator.common.mount.ExistingHideawayException;
|
||||
import org.cryptomator.common.mount.HideawayNotDirectoryException;
|
||||
import org.cryptomator.common.mount.IllegalMountPointException;
|
||||
import org.cryptomator.common.mount.MountPointCleanupFailedException;
|
||||
import org.cryptomator.common.mount.MountPointInUseException;
|
||||
@@ -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 ExistingHideawayException haeExc ? haeExc.getHideaway() : null;
|
||||
this.hideawayPath = exc instanceof HideawayNotDirectoryException haeExc ? haeExc.getHideaway() : null;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -81,7 +81,7 @@ public class UnlockInvalidMountPointController implements FxController {
|
||||
case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED;
|
||||
case MountPointNotExistingException x -> ExceptionType.NOT_EXISTING;
|
||||
case MountPointInUseException x -> ExceptionType.IN_USE;
|
||||
case ExistingHideawayException x -> ExceptionType.HIDEAWAY_EXISTS;
|
||||
case HideawayNotDirectoryException x -> ExceptionType.HIDEAWAY_NOT_DIR;
|
||||
case MountPointCleanupFailedException x -> ExceptionType.COULD_NOT_BE_CLEARED;
|
||||
case MountPointNotEmptyDirectoryException x -> ExceptionType.NOT_EMPTY_DIRECTORY;
|
||||
default -> ExceptionType.GENERIC;
|
||||
@@ -93,7 +93,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),
|
||||
HIDEAWAY_NOT_DIR("unlock.error.customPath.description.hideawayNotDir", 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);
|
||||
|
||||
@@ -131,7 +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.hideawayNotDir=The path "%3$s", which is used to preserve folder properties set by you for your mount path "%1$s", is not a folder. 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
|
||||
|
||||
Reference in New Issue
Block a user