Skip to content

Commit

Permalink
Show a dedicated message when mounting to an occupied Windows drive
Browse files Browse the repository at this point in the history
The error message was restored from 6395f17. Fixes #2309.
  • Loading branch information
sschuberth committed Jun 16, 2023
1 parent 5d796ef commit 71ba73b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/org/cryptomator/common/mount/Mounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ResourceBundle;

import static org.cryptomator.integrations.mount.MountCapability.MOUNT_AS_DRIVE_LETTER;
import static org.cryptomator.integrations.mount.MountCapability.MOUNT_TO_EXISTING_DIR;
Expand All @@ -28,13 +29,15 @@ public class Mounter {
private final Environment env;
private final WindowsDriveLetters driveLetters;
private final ObservableValue<ActualMountService> mountServiceObservable;
private final ResourceBundle resourceBundle;

@Inject
public Mounter(Settings settings, Environment env, WindowsDriveLetters driveLetters, ObservableValue<ActualMountService> mountServiceObservable) {
public Mounter(Settings settings, Environment env, WindowsDriveLetters driveLetters, ObservableValue<ActualMountService> mountServiceObservable, ResourceBundle resourceBundle) {
this.settings = settings;
this.env = env;
this.driveLetters = driveLetters;
this.mountServiceObservable = mountServiceObservable;
this.resourceBundle = resourceBundle;
}

private class SettledMounter {
Expand Down Expand Up @@ -97,7 +100,12 @@ private Runnable prepareMountPoint() throws IOException {
}
} else {
var mpIsDriveLetter = userChosenMountPoint.toString().matches("[A-Z]:\\\\");
if (!mpIsDriveLetter && canMountToParent && !canMountToDir) {
if (mpIsDriveLetter) {
if (driveLetters.getOccupied().contains(userChosenMountPoint)) {
var message = String.format(resourceBundle.getString("unlock.error.customPath.driveLetterOccupied"), userChosenMountPoint);
throw new IllegalMountPointException(message);
}
} else if (canMountToParent && !canMountToDir) {
MountWithinParentUtil.prepareParentNoMountPoint(userChosenMountPoint);
cleanup = () -> {
MountWithinParentUtil.cleanup(userChosenMountPoint);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/i18n/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ unlock.error.customPath.message=Unable to mount vault to custom path
unlock.error.customPath.description.notSupported=If you wish to keep using the custom path, please go to the preferences and select a volume type that supports it. Otherwise, go to the vault options and choose a supported mount point.
unlock.error.customPath.description.notExists=The custom mount path does not exist. Either create it in your local filesystem or change it in the vault options.
unlock.error.customPath.description.generic=You have selected a custom mount path for this vault, but using it failed with the message: %s
unlock.error.customPath.driveLetterOccupied=Drive letter "%s" is already in use.
## Hub
hub.noKeychain.message=Unable to access device key
hub.noKeychain.description=In order to unlock Hub vaults, a device key is required, which is secured using a keychain. To proceed, enable “%s” and select a keychain in the preferences.
Expand Down

0 comments on commit 71ba73b

Please sign in to comment.