mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-24 03:26:56 -04:00
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
This commit is contained in:
@@ -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<Path> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user