Added Dokany to volume type setting.

Restart no longer required, when changing preferred volume type.
References #207
This commit is contained in:
Sebastian Stenzel
2018-06-17 14:19:22 +02:00
parent aed35c17c8
commit 874c5506a7
7 changed files with 21 additions and 21 deletions

View File

@@ -77,9 +77,6 @@ public class SettingsController implements ViewController {
@FXML
private ChoiceBox<String> prefGvfsScheme;
@FXML
private Label volumeLabel;
@FXML
private ChoiceBox<VolumeImpl> volume;
@@ -98,7 +95,6 @@ public class SettingsController implements ViewController {
//NIOADAPTER
volume.getItems().addAll(getSupportedAdapters());
volume.setValue(settings.preferredVolumeImpl().get());
volume.setVisible(true);
volume.setConverter(new NioAdapterImplStringConverter());
//WEBDAV
@@ -131,9 +127,9 @@ public class SettingsController implements ViewController {
settings.debugMode().bind(debugModeCheckbox.selectedProperty());
}
//TODO: how to implement this?
private VolumeImpl[] getSupportedAdapters() {
return new VolumeImpl[]{VolumeImpl.FUSE, VolumeImpl.WEBDAV};
// TODO: filter depending on supported drivers
return VolumeImpl.values();
}
@Override

View File

@@ -8,7 +8,6 @@ import org.cryptomator.cryptofs.CryptoFileSystem;
import org.cryptomator.frontend.dokany.Mount;
import org.cryptomator.frontend.dokany.MountFactory;
@VaultModule.PerVault
public class DokanyVolume implements Volume {
private static final String FS_TYPE_NAME = "Cryptomator File System";

View File

@@ -20,7 +20,6 @@ import org.cryptomator.frontend.fuse.mount.Mount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@VaultModule.PerVault
public class FuseVolume implements Volume {
private static final Logger LOG = LoggerFactory.getLogger(FuseVolume.class);
@@ -34,7 +33,6 @@ public class FuseVolume implements Volume {
private final VaultSettings vaultSettings;
private Mount fuseMnt;
private CryptoFileSystem cfs;
private Path mountPath;
private boolean extraDirCreated;
@@ -46,7 +44,6 @@ public class FuseVolume implements Volume {
@Override
public void mount(CryptoFileSystem fs) throws IOException, FuseNotSupportedException, VolumeException {
this.cfs = fs;
String mountPath;
if (vaultSettings.usesIndividualMountPath().get()) {
//specific path given
@@ -57,7 +54,7 @@ public class FuseVolume implements Volume {
extraDirCreated = true;
}
this.mountPath = Paths.get(mountPath).toAbsolutePath();
mount();
mount(fs.getPath("/"));
}
private String createDirIfNotExist(String prefix, String dirName) throws IOException {
@@ -78,13 +75,13 @@ public class FuseVolume implements Volume {
}
}
private void mount() throws VolumeException {
private void mount(Path root) throws VolumeException {
try {
EnvironmentVariables envVars = EnvironmentVariables.create()
.withMountName(vaultSettings.mountName().getValue())
.withMountPath(mountPath)
.build();
this.fuseMnt = FuseMountFactory.getMounter().mount(cfs.getPath("/"), envVars);
this.fuseMnt = FuseMountFactory.getMounter().mount(root, envVars);
} catch (CommandFailedException e) {
throw new VolumeException("Unable to mount Filesystem", e);
}

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import javax.inject.Inject;
import javax.inject.Provider;
import javafx.application.Platform;
import javafx.beans.Observable;
@@ -52,6 +53,7 @@ public class Vault {
private final Settings settings;
private final VaultSettings vaultSettings;
private final Provider<Volume> volumeProvider;
private final AtomicReference<CryptoFileSystem> cryptoFileSystem = new AtomicReference<>();
private final ObjectProperty<State> state = new SimpleObjectProperty<State>(State.LOCKED);
@@ -62,10 +64,10 @@ public class Vault {
}
@Inject
Vault(Settings settings, VaultSettings vaultSettings, Volume volume) {
Vault(Settings settings, VaultSettings vaultSettings, Provider<Volume> volumeProvider) {
this.settings = settings;
this.vaultSettings = vaultSettings;
this.volume = volume;
this.volumeProvider = volumeProvider;
}
// ******************************************************************************
@@ -102,6 +104,7 @@ public class Vault {
state.set(State.PROCESSING);
});
CryptoFileSystem fs = getCryptoFileSystem(passphrase);
volume = volumeProvider.get();
volume.mount(fs);
Platform.runLater(() -> {
state.set(State.UNLOCKED);

View File

@@ -18,10 +18,13 @@ import org.cryptomator.common.settings.VaultSettings;
import dagger.Module;
import dagger.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Module
public class VaultModule {
private static final Logger LOG = LoggerFactory.getLogger(VaultModule.class);
private final VaultSettings vaultSettings;
public VaultModule(VaultSettings vaultSettings) {
@@ -42,14 +45,16 @@ public class VaultModule {
}
@Provides
@PerVault
public Volume provideVolume(Settings settings, WebDavVolume webDavVolume, FuseVolume fuseVolume, DokanyVolume dokanyVolume) {
VolumeImpl impl = settings.preferredVolumeImpl().get();
if (VolumeImpl.DOKANY == impl && dokanyVolume.isSupported()) {
VolumeImpl preferredImpl = settings.preferredVolumeImpl().get();
if (VolumeImpl.DOKANY == preferredImpl && dokanyVolume.isSupported()) {
return dokanyVolume;
} else if (VolumeImpl.FUSE == impl && fuseVolume.isSupported()) {
} else if (VolumeImpl.FUSE == preferredImpl && fuseVolume.isSupported()) {
return fuseVolume;
} else {
if (VolumeImpl.WEBDAV != preferredImpl) {
LOG.warn("Using WebDAV, because {} is not supported.", preferredImpl.getDisplayName());
}
assert webDavVolume.isSupported();
return webDavVolume;
}

View File

@@ -15,7 +15,6 @@ import javax.inject.Provider;
import java.net.InetAddress;
import java.net.UnknownHostException;
@VaultModule.PerVault
public class WebDavVolume implements Volume {
private static final String LOCALHOST_ALIAS = "cryptomator-vault";

View File

@@ -122,9 +122,10 @@ settings.webdav.port.apply=Apply
settings.webdav.prefGvfsScheme.label=WebDAV Scheme
settings.debugMode.label=Debug Mode *
settings.requiresRestartLabel=* Cryptomator needs to restart
settings.volume.label= Mount-Methode *
settings.volume.label=Preferred Volume Type
settings.volume.webdav=WebDAV
settings.volume.fuse=FUSE
settings.volume.dokany=Dokany
# tray icon
tray.menu.open=Open