diff --git a/main/pom.xml b/main/pom.xml index f2ef3a13a..124fcaedf 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -29,7 +29,7 @@ 1.0.9 1.0.1 - 0.2.3 + 0.3.0-SNAPSHOT 1.0.0 2.1 1.7.7 diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java index 0628b7187..eb306beaa 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.SystemUtils; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException; import org.cryptomator.frontend.webdav.ServerLifecycleException; +import org.cryptomator.frontend.webdav.mount.Mounter.CommandFailedException; import org.cryptomator.keychain.KeychainAccess; import org.cryptomator.ui.controls.SecPasswordField; import org.cryptomator.ui.model.Vault; @@ -350,7 +351,7 @@ public class UnlockController extends LocalizedFXMLViewController { messageText.setText(localization.getString("unlock.errorMessage.unauthenticVersionMac")); } }); - } catch (ServerLifecycleException e) { + } catch (ServerLifecycleException | CommandFailedException e) { LOG.error("Unlock failed for technical reasons.", e); Platform.runLater(() -> { messageText.setText(localization.getString("unlock.errorMessage.mountingFailed")); diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java index 4e584fba2..dd09ba681 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java +++ b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java @@ -14,6 +14,7 @@ import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collections; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -27,6 +28,9 @@ import org.cryptomator.cryptofs.CryptoFileSystemProperties; import org.cryptomator.cryptofs.CryptoFileSystemProvider; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.frontend.webdav.WebDavServer; +import org.cryptomator.frontend.webdav.mount.Mounter.CommandFailedException; +import org.cryptomator.frontend.webdav.mount.Mounter.Mount; +import org.cryptomator.frontend.webdav.servlet.WebDavServletController; import org.cryptomator.ui.model.VaultModule.PerVault; import org.cryptomator.ui.settings.VaultSettings; import org.cryptomator.ui.util.DeferredCloser; @@ -54,6 +58,9 @@ public class Vault { private final BooleanProperty mounted = new SimpleBooleanProperty(); private final AtomicReference cryptoFileSystem = new AtomicReference<>(); + private WebDavServletController servlet; + private Mount mount; + @Inject Vault(VaultSettings vaultSettings, WebDavServer server, DeferredCloser closer) { this.vaultSettings = vaultSettings; @@ -93,32 +100,48 @@ public class Vault { if (!server.isRunning()) { server.start(); } - server.startWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.getMountName()); + servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.getMountName()); + servlet.start(); + unlockSuccess = true; + + mount = servlet.mount(Collections.emptyMap()); + mountSuccess = true; } catch (IOException e) { - LOG.error("Unable to provide frontend", e); + LOG.error("Unable to provide filesystem", e); + } catch (CommandFailedException e) { + LOG.error("Unable to mount filesystem", e); } finally { // unlocked is a observable property and should only be changed by the FX application thread + final boolean finalUnlockSuccess = unlockSuccess; + final boolean finalMountSuccess = mountSuccess; Platform.runLater(() -> { - unlocked.set(unlockSuccess); - mounted.set(mountSuccess); + unlocked.set(finalUnlockSuccess); + mounted.set(finalMountSuccess); }); } } public synchronized void deactivateFrontend() throws Exception { + if (mount != null) { + mount.unmount(); + } + if (servlet != null) { + servlet.stop(); + } CryptoFileSystem fs = cryptoFileSystem.getAndSet(null); if (fs != null) { fs.close(); } - // TODO overheadhunter remove servlet from server Platform.runLater(() -> { mounted.set(false); unlocked.set(false); }); } - public synchronized void reveal() { - // TODO overheadhunter implement mounting utility in webdav-nio-adapter + public void reveal() throws CommandFailedException { + if (mount != null) { + mount.reveal(); + } } // ******************************************************************************