diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index 2c476e20d..f29186865 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -40,9 +40,6 @@ public final class MountWithinParentUtil { } //... (now) without hideaway - checkIsDirectory(mountPoint); - checkIsEmpty(mountPoint); - Files.move(mountPoint, hideaway); if (SystemUtils.IS_OS_WINDOWS) { Files.setAttribute(hideaway, WIN_HIDDEN_ATTR, true, LinkOption.NOFOLLOW_LINKS); @@ -68,6 +65,8 @@ public final class MountWithinParentUtil { return false; } if (!Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isOther()) { + checkIsDirectory(path); + checkIsEmpty(path); return true; } if (Files.exists(path /* FOLLOW_LINKS */)) { //Both junction and target exist diff --git a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java index 09648a98e..bfdda8fa0 100644 --- a/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java +++ b/src/test/java/org/cryptomator/common/mount/MountWithinParentUtilTest.java @@ -89,27 +89,27 @@ class MountWithinParentUtilTest { void testPrepareBothExistMountNotDir(@TempDir Path parentDir) throws IOException { var mount = parentDir.resolve("mount"); var hideaway = getHideaway(mount); - Files.createDirectory(hideaway); + Files.createFile(hideaway); Files.createFile(mount); assertThrows(MountPointNotEmptyDirectoryException.class, () -> { - prepareParentNoMountPoint(mount); + prepareParentNoMountPoint(mount); //Must not throw something related to hideaway }); - assertTrue(Files.notExists(hideaway, NOFOLLOW_LINKS)); + assertTrue(Files.exists(hideaway, NOFOLLOW_LINKS)); } @Test void testPrepareBothExistMountNotEmpty(@TempDir Path parentDir) throws IOException { var mount = parentDir.resolve("mount"); var hideaway = getHideaway(mount); - Files.createDirectory(hideaway); + Files.createFile(hideaway); Files.createDirectory(mount); Files.createFile(mount.resolve("dummy")); assertThrows(MountPointNotEmptyDirectoryException.class, () -> { - prepareParentNoMountPoint(mount); + prepareParentNoMountPoint(mount); //Must not throw something related to hideaway }); - assertTrue(Files.notExists(hideaway, NOFOLLOW_LINKS)); + assertTrue(Files.exists(hideaway, NOFOLLOW_LINKS)); } @Test