From 96ebb67085c17960772bdaddb70faf58c81f9c90 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Wed, 12 Jul 2023 19:17:37 +0200 Subject: [PATCH] Applied suggestions from code review See: https://github.com/cryptomator/cryptomator/pull/2996#discussion_r1260955250 --- .../cryptomator/common/mount/MountWithinParentUtil.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index 04e84f64e..cb9992359 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/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); }