|
@@ -21,6 +21,7 @@ import org.cryptomator.common.settings.Settings;
|
|
|
import org.cryptomator.common.settings.VaultSettings;
|
|
|
import org.cryptomator.cryptofs.CryptoFileSystem;
|
|
|
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
|
|
|
+import org.cryptomator.cryptofs.CryptoFileSystemProperties.FileSystemFlags;
|
|
|
import org.cryptomator.cryptofs.CryptoFileSystemProvider;
|
|
|
import org.cryptomator.cryptolib.api.CryptoException;
|
|
|
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
|
|
@@ -38,6 +39,8 @@ import java.nio.file.NoSuchFileException;
|
|
|
import java.nio.file.NotDirectoryException;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Predicate;
|
|
@@ -78,9 +81,13 @@ public class Vault {
|
|
|
}
|
|
|
|
|
|
private CryptoFileSystem unlockCryptoFileSystem(CharSequence passphrase) throws NoSuchFileException, IOException, InvalidPassphraseException, CryptoException {
|
|
|
+ List<FileSystemFlags> flags = new ArrayList<>();
|
|
|
+ if (vaultSettings.usesReadOnlyMode().get()) {
|
|
|
+ flags.add(FileSystemFlags.READONLY);
|
|
|
+ }
|
|
|
CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties() //
|
|
|
.withPassphrase(passphrase) //
|
|
|
- .withFlags() //
|
|
|
+ .withFlags(flags) //
|
|
|
.withMasterkeyFilename(MASTERKEY_FILENAME) //
|
|
|
.build();
|
|
|
return CryptoFileSystemProvider.newFileSystem(getPath(), fsProps);
|