From ea6925f9056bf0763ff6bdb255a5cae3d6600acb Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Wed, 19 Aug 2020 11:39:34 +0200 Subject: [PATCH] Replaced #wrapAsIMPE() with explicit call to IMPExc See: https://github.com/cryptomator/cryptomator/pull/1307#discussion_r472872373 https://github.com/cryptomator/cryptomator/pull/1307#discussion_r472859488 https://github.com/cryptomator/cryptomator/pull/1307#discussion_r472827776 --- .../common/mountpoint/CustomMountPointChooser.java | 14 +++++--------- .../mountpoint/TemporaryMountPointChooser.java | 6 +----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/mountpoint/CustomMountPointChooser.java b/main/commons/src/main/java/org/cryptomator/common/mountpoint/CustomMountPointChooser.java index 2a69b8cc3..a186696cd 100644 --- a/main/commons/src/main/java/org/cryptomator/common/mountpoint/CustomMountPointChooser.java +++ b/main/commons/src/main/java/org/cryptomator/common/mountpoint/CustomMountPointChooser.java @@ -48,33 +48,29 @@ public class CustomMountPointChooser implements MountPointChooser { Path parent = mountPoint.getParent(); if (!Files.isDirectory(parent)) { - throw wrapAsIMPE(new NotDirectoryException(parent.toString())); + throw new InvalidMountPointException(new NotDirectoryException(parent.toString())); } //We must use #notExists() here because notExists =/= !exists (see docs) if (!Files.notExists(mountPoint, LinkOption.NOFOLLOW_LINKS)) { //File exists OR can't be determined - throw wrapAsIMPE(new FileAlreadyExistsException(mountPoint.toString())); + throw new InvalidMountPointException(new FileAlreadyExistsException(mountPoint.toString())); } } else if(requirement == MountPointRequirement.EMPTY_MOUNT_POINT) { //This is the case for Windows when using Dokany //and for Linux and Mac if (!Files.isDirectory(mountPoint)) { - throw wrapAsIMPE(new NotDirectoryException(mountPoint.toString())); + throw new InvalidMountPointException(new NotDirectoryException(mountPoint.toString())); } try (DirectoryStream ds = Files.newDirectoryStream(mountPoint)) { if (ds.iterator().hasNext()) { - throw wrapAsIMPE(new DirectoryNotEmptyException(mountPoint.toString())); + throw new InvalidMountPointException(new DirectoryNotEmptyException(mountPoint.toString())); } } catch (IOException exception) { - throw wrapAsIMPE(exception); + throw new InvalidMountPointException(exception); } } LOG.debug("Successfully checked custom mount point: {}", mountPoint); return false; } - - private InvalidMountPointException wrapAsIMPE(Exception exception) { - return new InvalidMountPointException(exception); - } } diff --git a/main/commons/src/main/java/org/cryptomator/common/mountpoint/TemporaryMountPointChooser.java b/main/commons/src/main/java/org/cryptomator/common/mountpoint/TemporaryMountPointChooser.java index 7c3239fc1..f1dccce06 100644 --- a/main/commons/src/main/java/org/cryptomator/common/mountpoint/TemporaryMountPointChooser.java +++ b/main/commons/src/main/java/org/cryptomator/common/mountpoint/TemporaryMountPointChooser.java @@ -72,7 +72,7 @@ public class TemporaryMountPointChooser implements MountPointChooser { return true; } } catch (IOException exception) { - throw wrapAsIMPE(exception); + throw new InvalidMountPointException(exception); } } @@ -85,8 +85,4 @@ public class TemporaryMountPointChooser implements MountPointChooser { LOG.warn("Could not delete mount point: {}", e.getMessage()); } } - - private InvalidMountPointException wrapAsIMPE(Exception exception) { - return new InvalidMountPointException(exception); - } }