lock vault on external unmount

This commit is contained in:
Armin Schrenk
2021-03-23 12:52:38 +01:00
parent c05e00d32a
commit 17dc32bb79

View File

@@ -42,6 +42,7 @@ import java.util.EnumSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
@@ -139,7 +140,14 @@ public class Vault {
cryptoFileSystem.set(fs);
try {
volume = volumeProvider.get();
volume.mount(fs, getEffectiveMountFlags());
volume.mount(fs, getEffectiveMountFlags()).handle((voit, throwable) -> {
destroyCryptoFileSystem();
setState(VaultState.LOCKED); //TODO: possible race conditions of the vault state. Use Platform.runLater()?
if (throwable != null) {
LOG.warn("Unexpected unmount and lock of vault" + getDisplayName(), throwable);
}
return CompletableFuture.completedFuture(null);
});
} catch (Exception e) {
destroyCryptoFileSystem();
throw e;