From 1c34402c87077252871cea2cbf4ec5f546adcb4d Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Tue, 25 Jul 2023 13:17:21 +0200 Subject: [PATCH] Applied minor corrections See: https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1273277251 https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1273280687 https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1273287847 --- .../cryptomator/common/mount/MountWithinParentUtil.java | 8 ++++---- src/main/resources/i18n/strings.properties | 2 +- .../common/mount/MountWithinParentUtilTest.java | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index f29186865..92023279c 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -65,8 +65,8 @@ public final class MountWithinParentUtil { return false; } if (!Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isOther()) { - checkIsDirectory(path); - checkIsEmpty(path); + checkIsMountPointDirectory(path); + checkIsMountPointEmpty(path); return true; } if (Files.exists(path /* FOLLOW_LINKS */)) { //Both junction and target exist @@ -119,7 +119,7 @@ public final class MountWithinParentUtil { } } - private static void checkIsDirectory(Path toCheck) throws IllegalMountPointException { + private static void checkIsMountPointDirectory(Path toCheck) throws IllegalMountPointException { if (!Files.isDirectory(toCheck, LinkOption.NOFOLLOW_LINKS)) { throw new MountPointNotEmptyDirectoryException(toCheck, "Mountpoint is not a directory: " + toCheck); } @@ -131,7 +131,7 @@ public final class MountWithinParentUtil { } } - private static void checkIsEmpty(Path toCheck) throws IllegalMountPointException, IOException { + private static void checkIsMountPointEmpty(Path toCheck) throws IllegalMountPointException, IOException { try (var dirStream = Files.list(toCheck)) { if (dirStream.findFirst().isPresent()) { throw new MountPointNotEmptyDirectoryException(toCheck, "Mountpoint directory is not empty: " + toCheck); diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index 4a3e64ee5..69a22855d 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -130,7 +130,7 @@ unlock.success.revealBtn=Reveal Drive 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=The custom mount path "%s" is already in use. +unlock.error.customPath.description.inUse=The drive letter or custom mount path "%s" is already in use. unlock.error.customPath.description.hideawayNotDir=The temporary, hidden file "%3$s" used for unlock could not be removed. Please check the file and then delete it manually. 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. diff --git a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java index 2a63d3af8..b9d0820a9 100644 --- a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java +++ b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java @@ -206,7 +206,6 @@ class MountWithinParentUtilTest { var mount = Path.of("C:\\mount"); var hideaway = getHideaway(mount); - assertEquals(mount.getParent().toAbsolutePath(), Path.of("C:\\").toAbsolutePath()); assertEquals(mount.getParent(), hideaway.getParent()); assertEquals(mount.getParent().resolve(".~$mount.tmp"), hideaway); assertEquals(mount.getParent().toAbsolutePath() + ".~$mount.tmp", hideaway.toAbsolutePath().toString()); @@ -218,7 +217,6 @@ class MountWithinParentUtilTest { var mount = Path.of("/mount"); var hideaway = getHideaway(mount); - assertEquals(mount.getParent().toAbsolutePath(), Path.of("/").toAbsolutePath()); assertEquals(mount.getParent(), hideaway.getParent()); assertEquals(mount.getParent().resolve(".~$mount.tmp"), hideaway); assertEquals(mount.getParent().toAbsolutePath() + ".~$mount.tmp", hideaway.toAbsolutePath().toString());