mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
Default to FUSE. Use WebDAV as Backup, if FUSE isn't supported
This commit is contained in:
@@ -32,7 +32,7 @@ public class Settings {
|
||||
public static final int DEFAULT_NUM_TRAY_NOTIFICATIONS = 3;
|
||||
public static final String DEFAULT_GVFS_SCHEME = "dav";
|
||||
public static final boolean DEFAULT_DEBUG_MODE = false;
|
||||
public static final VolumeImpl DEFAULT_VOLUME_IMPL = VolumeImpl.WEBDAV;
|
||||
public static final VolumeImpl DEFAULT_VOLUME_IMPL = VolumeImpl.FUSE;
|
||||
|
||||
private final ObservableList<VaultSettings> directories = FXCollections.observableArrayList(VaultSettings::observables);
|
||||
private final BooleanProperty checkForUpdates = new SimpleBooleanProperty(DEFAULT_CHECK_FOR_UDPATES);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<cryptomator.cryptofs.version>1.5.1</cryptomator.cryptofs.version>
|
||||
<cryptomator.webdav.version>1.0.4</cryptomator.webdav.version>
|
||||
<cryptomator.jni.version>2.0.0</cryptomator.jni.version>
|
||||
<cryptomator.fuse.version>0.1.2</cryptomator.fuse.version>
|
||||
<cryptomator.fuse.version>0.1.3</cryptomator.fuse.version>
|
||||
|
||||
<commons-io.version>2.5</commons-io.version>
|
||||
<commons-lang3.version>3.6</commons-lang3.version>
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package org.cryptomator.ui.model;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
import org.cryptomator.cryptofs.CryptoFileSystem;
|
||||
|
||||
import org.cryptomator.frontend.fuse.mount.EnvironmentVariables;
|
||||
import org.cryptomator.frontend.fuse.mount.FuseMount;
|
||||
import org.cryptomator.frontend.fuse.mount.FuseMountFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryNotEmptyException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
import org.cryptomator.cryptofs.CryptoFileSystem;
|
||||
import org.cryptomator.frontend.fuse.mount.EnvironmentVariables;
|
||||
import org.cryptomator.frontend.fuse.mount.FuseMountFactory;
|
||||
import org.cryptomator.frontend.fuse.mount.FuseNotSupportedException;
|
||||
import org.cryptomator.frontend.fuse.mount.Mount;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@VaultModule.PerVault
|
||||
public class FuseVolume implements Volume {
|
||||
|
||||
@@ -28,10 +29,10 @@ public class FuseVolume implements Volume {
|
||||
private static final String DEFAULT_MOUNTROOTPATH_MAC = System.getProperty("user.home") + "/Library/Application Support/Cryptomator";
|
||||
private static final String DEFAULT_MOUNTROOTPATH_LINUX = System.getProperty("user.home") + "/.Cryptomator";
|
||||
|
||||
private final FuseMount fuseMnt;
|
||||
private final VaultSettings vaultSettings;
|
||||
private final WindowsDriveLetters windowsDriveLetters;
|
||||
|
||||
private Mount fuseMnt;
|
||||
private CryptoFileSystem cfs;
|
||||
private Path mountPath;
|
||||
private boolean extraDirCreated;
|
||||
@@ -40,12 +41,11 @@ public class FuseVolume implements Volume {
|
||||
public FuseVolume(VaultSettings vaultSettings, WindowsDriveLetters windowsDriveLetters) {
|
||||
this.vaultSettings = vaultSettings;
|
||||
this.windowsDriveLetters = windowsDriveLetters;
|
||||
this.fuseMnt = FuseMountFactory.createMountObject();
|
||||
this.extraDirCreated = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(CryptoFileSystem fs) throws IOException {
|
||||
public void prepare(CryptoFileSystem fs) throws IOException, FuseNotSupportedException {
|
||||
this.cfs = fs;
|
||||
String mountPath;
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
@@ -62,8 +62,7 @@ public class FuseVolume implements Volume {
|
||||
mountPath = vaultSettings.individualMountPath().get();
|
||||
} else {
|
||||
//choose default path & create extra directory
|
||||
mountPath = createDirIfNotExist(SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX,
|
||||
vaultSettings.mountName().get());
|
||||
mountPath = createDirIfNotExist(SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX, vaultSettings.mountName().get());
|
||||
extraDirCreated = true;
|
||||
}
|
||||
this.mountPath = Paths.get(mountPath).toAbsolutePath();
|
||||
@@ -84,10 +83,10 @@ public class FuseVolume implements Volume {
|
||||
try {
|
||||
EnvironmentVariables envVars = EnvironmentVariables.create()
|
||||
.withMountName(vaultSettings.mountName().getValue())
|
||||
.withMountPath(mountPath.toString())
|
||||
.withMountPath(mountPath)
|
||||
.build();
|
||||
fuseMnt.mount(cfs.getPath("/"), envVars);
|
||||
} catch (Exception e) {
|
||||
this.fuseMnt = FuseMountFactory.getMounter().mount(cfs.getPath("/"), envVars);
|
||||
} catch (org.cryptomator.frontend.fuse.mount.CommandFailedException e) {
|
||||
throw new CommandFailedException("Unable to mount Filesystem", e);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +94,7 @@ public class FuseVolume implements Volume {
|
||||
@Override
|
||||
public void reveal() throws CommandFailedException {
|
||||
try {
|
||||
fuseMnt.reveal();
|
||||
fuseMnt.revealInFileManager();
|
||||
} catch (org.cryptomator.frontend.fuse.mount.CommandFailedException e) {
|
||||
LOG.info("Revealing the vault in file manger failed: " + e.getMessage());
|
||||
throw new CommandFailedException(e);
|
||||
@@ -104,24 +103,16 @@ public class FuseVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public synchronized void unmount() throws CommandFailedException {
|
||||
if (cfs.getStats().pollBytesRead() == 0 && cfs.getStats().pollBytesWritten() == 0) {
|
||||
unmountRaw();
|
||||
} else {
|
||||
throw new CommandFailedException("Pending read or write operations.");
|
||||
try {
|
||||
fuseMnt.close();
|
||||
} catch (org.cryptomator.frontend.fuse.mount.CommandFailedException e) {
|
||||
throw new CommandFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void unmountForced() throws CommandFailedException {
|
||||
this.unmountRaw();
|
||||
}
|
||||
|
||||
private synchronized void unmountRaw() throws CommandFailedException {
|
||||
try {
|
||||
fuseMnt.unmount();
|
||||
} catch (org.cryptomator.frontend.fuse.mount.CommandFailedException e) {
|
||||
throw new CommandFailedException(e);
|
||||
}
|
||||
unmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,22 +128,17 @@ public class FuseVolume implements Volume {
|
||||
|
||||
@Override
|
||||
public String getMountUri() {
|
||||
return Paths.get(fuseMnt.getMountPath()).toUri().toString();
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: change this to a real implementation
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return true;
|
||||
return FuseMountFactory.isFuseSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsForcedUnmount() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,10 +46,15 @@ public class VaultModule {
|
||||
public Volume provideNioAdpater(Settings settings, WebDavVolume webDavVolume, FuseVolume fuseVolume) {
|
||||
VolumeImpl impl = settings.volumeImpl().get();
|
||||
switch (impl) {
|
||||
case FUSE:
|
||||
if (fuseVolume.isSupported()) {
|
||||
return fuseVolume;
|
||||
} else {
|
||||
settings.volumeImpl().set(VolumeImpl.WEBDAV);
|
||||
// fallthrough to WEBDAV
|
||||
}
|
||||
case WEBDAV:
|
||||
return webDavVolume;
|
||||
case FUSE:
|
||||
return fuseVolume;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported NioAdapter: " + impl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user