Browse Source

Applied suggestions from code review

See: https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1260955250
JaniruTEC 2 years ago
parent
commit
96ebb67085

+ 3 - 6
src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java

@@ -4,6 +4,7 @@ import org.apache.commons.lang3.SystemUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.file.DirectoryNotEmptyException;
 import java.nio.file.FileAlreadyExistsException;
@@ -74,18 +75,14 @@ public final class MountWithinParentUtil {
 
 	private static boolean removeResidualJunction(Path path) throws MountPointPreparationException {
 		try {
-			if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
-				return false;
-			}
-			if (!SystemUtils.IS_OS_WINDOWS) { //So far this is only a problem on Windows
-				return true;
-			}
 			if (Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isOther()) {
 				LOG.info("Mountpoint \"{}\" is still a junction. Deleting it.", path);
 				Files.delete(path); //Throws if path is also a non-empty folder
 				return false;
 			}
 			return true;
+		} catch (FileNotFoundException e) {
+			return false;
 		} catch (IOException e) {
 			throw new MountPointPreparationException(e);
 		}