diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java index 91291752e..ff0bc1632 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/WebDavVolume.java @@ -26,6 +26,7 @@ public class WebDavVolume implements Volume { private final Provider serverProvider; private final VaultSettings vaultSettings; private final Settings settings; + private final WindowsDriveLetters windowsDriveLetters; private WebDavServer server; private WebDavServletController servlet; @@ -33,10 +34,11 @@ public class WebDavVolume implements Volume { private Path mountPoint; @Inject - public WebDavVolume(Provider serverProvider, VaultSettings vaultSettings, Settings settings) { + public WebDavVolume(Provider serverProvider, VaultSettings vaultSettings, Settings settings, WindowsDriveLetters windowsDriveLetters) { this.serverProvider = serverProvider; this.vaultSettings = vaultSettings; this.settings = settings; + this.windowsDriveLetters = windowsDriveLetters; } @Override @@ -62,8 +64,17 @@ public class WebDavVolume implements Volume { if (servlet == null) { throw new IllegalStateException("Mounting requires unlocked WebDAV servlet."); } + + //on windows, prevent an automatic drive letter selection in the upstream library. Either we choose already a specifc one or there is no free. + Supplier driveLetterSupplier; + if(System.getProperty("os.name").toLowerCase().contains("windows") && vaultSettings.winDriveLetter().isEmpty().get()) { + driveLetterSupplier = () -> windowsDriveLetters.getAvailableDriveLetter().orElse(null); + } else { + driveLetterSupplier = () -> vaultSettings.winDriveLetter().get(); + } + MountParams mountParams = MountParams.create() // - .withWindowsDriveLetter(vaultSettings.winDriveLetter().get()) // + .withWindowsDriveLetter(driveLetterSupplier.get()) // .withPreferredGvfsScheme(settings.preferredGvfsScheme().get().getPrefix())// .withWebdavHostname(getLocalhostAliasOrNull()) // .build();