mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-23 05:01:28 +00:00
Improved unmounting (failing, if encrypted drive is still busy)
This commit is contained in:
@@ -55,15 +55,16 @@ public class WebDavServlet extends AbstractWebdavServlet {
|
||||
public void destroy() {
|
||||
backgroundTaskExecutor.shutdown();
|
||||
try {
|
||||
final boolean tasksFinished = backgroundTaskExecutor.awaitTermination(10, TimeUnit.SECONDS);
|
||||
final boolean tasksFinished = backgroundTaskExecutor.awaitTermination(2, TimeUnit.SECONDS);
|
||||
if (!tasksFinished) {
|
||||
backgroundTaskExecutor.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
backgroundTaskExecutor.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
super.destroy();
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,9 +144,7 @@ public class UnlockController implements Initializable {
|
||||
progressIndicator.setVisible(false);
|
||||
setControlsDisabled(false);
|
||||
if (vault.isUnlocked() && !mountSuccess) {
|
||||
vault.getCryptor().swipeSensitiveData();
|
||||
vault.stopServer();
|
||||
vault.setUnlocked(false);
|
||||
}
|
||||
if (mountSuccess && listener != null) {
|
||||
listener.didUnlock(this);
|
||||
|
||||
@@ -27,8 +27,7 @@ import javafx.util.Duration;
|
||||
|
||||
import org.cryptomator.crypto.CryptorIOSampling;
|
||||
import org.cryptomator.ui.model.Vault;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.cryptomator.ui.util.mount.CommandFailedException;
|
||||
|
||||
public class UnlockedController implements Initializable {
|
||||
|
||||
@@ -47,18 +46,21 @@ public class UnlockedController implements Initializable {
|
||||
@FXML
|
||||
private NumberAxis xAxis;
|
||||
|
||||
@Inject
|
||||
public UnlockedController() {
|
||||
super();
|
||||
}
|
||||
private ResourceBundle rb;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
this.rb = rb;
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void didClickCloseVault(ActionEvent event) {
|
||||
vault.unmount();
|
||||
try {
|
||||
vault.unmount();
|
||||
} catch (CommandFailedException e) {
|
||||
messageLabel.setText(rb.getString("unlocked.label.unmountFailed"));
|
||||
return;
|
||||
}
|
||||
vault.stopServer();
|
||||
vault.setUnlocked(false);
|
||||
if (listener != null) {
|
||||
|
||||
@@ -88,9 +88,14 @@ public class Vault implements Serializable {
|
||||
}
|
||||
|
||||
public void stopServer() {
|
||||
unmount();
|
||||
try {
|
||||
unmount();
|
||||
} catch (CommandFailedException e) {
|
||||
LOG.warn("Unmounting failed. Locking anyway...", e);
|
||||
}
|
||||
webDavServlet.close();
|
||||
cryptor.swipeSensitiveData();
|
||||
setUnlocked(false);
|
||||
namesOfResourcesWithInvalidMac.clear();
|
||||
}
|
||||
|
||||
@@ -108,8 +113,12 @@ public class Vault implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void unmount() {
|
||||
webDavMount.close();
|
||||
public void unmount() throws CommandFailedException {
|
||||
final WebDavMount mnt = webDavMount.get().orElse(null);
|
||||
if (mnt != null) {
|
||||
mnt.unmount();
|
||||
}
|
||||
webDavMount = DeferredClosable.empty();
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package org.cryptomator.ui.util.mount;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.ui.util.command.Script;
|
||||
@@ -28,7 +29,8 @@ final class MacOsXWebDavMounter implements WebDavMounterStrategy {
|
||||
|
||||
@Override
|
||||
public WebDavMount mount(URI uri, String name) throws CommandFailedException {
|
||||
final String path = "/Volumes/Cryptomator" + uri.getRawPath().replace('/', '_');
|
||||
// we don't use the uri to derive a path, as it *could* be longer than 255 chars.
|
||||
final String path = "/Volumes/Cryptomator_" + UUID.randomUUID().toString();
|
||||
final Script mountScript = Script.fromLines(
|
||||
"mkdir \"$MOUNT_PATH\"",
|
||||
"mount_webdav -S -v $MOUNT_NAME \"$DAV_AUTHORITY$DAV_PATH\" \"$MOUNT_PATH\"",
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
</LineChart>
|
||||
|
||||
<!-- Row 1 -->
|
||||
<Button text="%unlocked.button.lock" defaultButton="true" GridPane.rowIndex="1" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="RIGHT" prefWidth="150.0" onAction="#didClickCloseVault" focusTraversable="false"/>
|
||||
<Label fx:id="messageLabel" GridPane.rowIndex="1" GridPane.columnIndex="0" />
|
||||
<Button text="%unlocked.button.lock" defaultButton="true" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.halignment="RIGHT" prefWidth="150.0" onAction="#didClickCloseVault" focusTraversable="false"/>
|
||||
</children>
|
||||
</GridPane>
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ changePassword.infoMessage.success=Password changed.
|
||||
|
||||
# unlocked.fxml
|
||||
unlocked.button.lock=Lock vault
|
||||
unlocked.label.unmountFailed=Ejecting drive failed.
|
||||
unlocked.ioGraph.yAxis.label=Throughput (MiB/s)
|
||||
|
||||
# mac_warnings.fxml
|
||||
|
||||
Reference in New Issue
Block a user