Refactored Vault, MPCs, Unlock to integrate better with latest changes

Removed delegate to Volume#getMountPointRequirement() from Vault
Added getter for the Vault's Volume (#getVolume())

Changed CustomMountPointChooser to use VaultSettings instead of Vault for the constructor/field declaration
Updated CustomMountPointChooser#isApplicable() to be disabled when using FUSE on Windows (without useExperimentalFuse)
Updated CustomMountPointChooser to call Volume#getMountPointRequirement() directly

Replaced OS-Check in TemporaryMountPointChooser with MPR-Check

Replaced call to Vault#getMountPointRequirement() with call to Vault#getVolume() (and Volume#getMountPointRequirement()) in UnlockInvalidMountPointController and UnlockWorkflow
Cleaned up UnlockWorkflow
This commit is contained in:
JaniruTEC
2020-10-07 23:19:24 +02:00
parent 9329311491
commit b5efe39eb8
5 changed files with 43 additions and 26 deletions
@@ -38,7 +38,7 @@ public class UnlockInvalidMountPointController implements FxController {
}
public boolean getMustExist() {
MountPointRequirement requirement = vault.getMountPointRequirement();
MountPointRequirement requirement = vault.getVolume().orElseThrow(() -> new IllegalStateException("Invalid Mountpoint without a Volume?!")).getMountPointRequirement();
assert requirement != MountPointRequirement.NONE; //An invalid MountPoint with no required MountPoint doesn't seem sensible
assert requirement != MountPointRequirement.PARENT_OPT_MOUNT_POINT; //Not implemented anywhere (yet)
@@ -157,7 +157,7 @@ public class UnlockWorkflow extends Task<Boolean> {
}
private void handleInvalidMountPoint(InvalidMountPointException impExc) {
MountPointRequirement requirement = vault.getMountPointRequirement();
MountPointRequirement requirement = vault.getVolume().orElseThrow(() -> new IllegalStateException("Invalid Mountpoint without a Volume?!", impExc)).getMountPointRequirement();
assert requirement != MountPointRequirement.NONE; //An invalid MountPoint with no required MountPoint doesn't seem sensible
assert requirement != MountPointRequirement.PARENT_OPT_MOUNT_POINT; //Not implemented anywhere (yet)
@@ -165,14 +165,14 @@ public class UnlockWorkflow extends Task<Boolean> {
//Cause is either null (cause the IMPE was thrown directly, e.g. because no MPC succeeded)
//or the cause was not an Exception (but some other kind of Throwable)
//Either way: Handle as generic error
if(!(cause instanceof Exception)) {
if (!(cause instanceof Exception)) {
handleGenericError(impExc);
return;
}
//From here on handle the cause, not the caught exception
if(cause instanceof NotDirectoryException) {
if(requirement == MountPointRequirement.PARENT_NO_MOUNT_POINT) {
if (cause instanceof NotDirectoryException) {
if (requirement == MountPointRequirement.PARENT_NO_MOUNT_POINT) {
LOG.error("Unlock failed. Parent folder is missing: {}", cause.getMessage());
} else {
LOG.error("Unlock failed. Mountpoint doesn't exist (needs to be a folder): {}", cause.getMessage());
@@ -181,13 +181,13 @@ public class UnlockWorkflow extends Task<Boolean> {
return;
}
if(cause instanceof FileAlreadyExistsException) {
if (cause instanceof FileAlreadyExistsException) {
LOG.error("Unlock failed. Mountpoint already exists: {}", cause.getMessage());
showInvalidMountPointScene();
return;
}
if(cause instanceof DirectoryNotEmptyException) {
if (cause instanceof DirectoryNotEmptyException) {
LOG.error("Unlock failed. Mountpoint not an empty directory: {}", cause.getMessage());
showInvalidMountPointScene();
return;