소스 검색

Fixed thrown exception

JaniruTEC 1 년 전
부모
커밋
3ea6da3c6d
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java

+ 8 - 4
src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java

@@ -30,7 +30,7 @@ public final class MountWithinParentUtil {
 		if (!mpExists && !hideExists) { //neither mountpoint nor hideaway exist
 			throw new MountPointNotExistingException(mountPoint);
 		} else if (!mpExists) { //only hideaway exists
-			checkIsDirectory(hideaway);
+			checkIsHideawayDirectory(mountPoint, hideaway);
 			LOG.info("Mountpoint {} seems to be not properly cleaned up. Will be fixed on unmount.", mountPoint);
 			try {
 				if (SystemUtils.IS_OS_WINDOWS) {
@@ -86,9 +86,7 @@ public final class MountWithinParentUtil {
 	}
 
 	private static void removeResidualHideaway(Path mountPoint, Path hideaway) throws IOException {
-		if (!Files.isDirectory(hideaway, LinkOption.NOFOLLOW_LINKS)) {
-			throw new HideawayNotDirectoryException(mountPoint, hideaway);
-		}
+		checkIsHideawayDirectory(mountPoint, hideaway);
 		Files.delete(hideaway); //Fails if not empty
 	}
 
@@ -134,6 +132,12 @@ public final class MountWithinParentUtil {
 		}
 	}
 
+	private static void checkIsHideawayDirectory(Path mountPoint, Path hideawayToCheck) {
+		if (!Files.isDirectory(hideawayToCheck, LinkOption.NOFOLLOW_LINKS)) {
+			throw new HideawayNotDirectoryException(mountPoint, hideawayToCheck);
+		}
+	}
+
 	private static void checkIsEmpty(Path toCheck) throws IllegalMountPointException, IOException {
 		try (var dirStream = Files.list(toCheck)) {
 			if (dirStream.findFirst().isPresent()) {