- fixes folder creation and automounting on Linux

- using IPv6 address for mounting on Windows only (hostnames on OS X and Linux)
This commit is contained in:
Sebastian Stenzel 2015-02-22 21:04:46 +01:00
parent 676cb10ef0
commit 507e21f8a3
4 changed files with 11 additions and 11 deletions

View File

@ -16,6 +16,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.crypto.Cryptor; import org.cryptomator.crypto.Cryptor;
import org.cryptomator.webdav.jackrabbit.WebDavServlet; import org.cryptomator.webdav.jackrabbit.WebDavServlet;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public final class WebDavServer { public final class WebDavServer {
private static final Logger LOG = LoggerFactory.getLogger(WebDavServer.class); private static final Logger LOG = LoggerFactory.getLogger(WebDavServer.class);
private static final String LOCALHOST = "::1"; private static final String LOCALHOST = SystemUtils.IS_OS_WINDOWS ? "::1" : "localhost";
private static final int MAX_PENDING_REQUESTS = 200; private static final int MAX_PENDING_REQUESTS = 200;
private static final int MAX_THREADS = 200; private static final int MAX_THREADS = 200;
private static final int MIN_THREADS = 4; private static final int MIN_THREADS = 4;

View File

@ -15,6 +15,7 @@ import java.nio.file.Path;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import org.apache.commons.collections4.BidiMap; import org.apache.commons.collections4.BidiMap;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
@ -154,7 +155,7 @@ class DavLocatorFactoryImpl implements DavLocatorFactory, SensitiveDataSwipeList
private DavResourceLocatorImpl(String prefix, String resourcePath) { private DavResourceLocatorImpl(String prefix, String resourcePath) {
this.prefix = prefix; this.prefix = prefix;
this.resourcePath = resourcePath; this.resourcePath = FilenameUtils.normalizeNoEndSeparator(resourcePath, true);
} }
@Override @Override

View File

@ -40,15 +40,13 @@ final class LinuxGvfsWebDavMounter implements WebDavMounterStrategy {
public WebDavMount mount(URI uri, String name) throws CommandFailedException { public WebDavMount mount(URI uri, String name) throws CommandFailedException {
final Script mountScript = Script.fromLines( final Script mountScript = Script.fromLines(
"set -x", "set -x",
"gvfs-mount \"dav://localhost:$DAV_PORT$DAV_PATH\"", "gvfs-mount \"dav:$DAV_SSP\"",
"xdg-open \"dav://localhost:$DAV_PORT$DAV_PATH\"") "xdg-open \"dav:$DAV_SSP\"")
.addEnv("DAV_PORT", String.valueOf(uri.getPort())) .addEnv("DAV_SSP", uri.getRawSchemeSpecificPart());
.addEnv("DAV_PATH", uri.getRawPath());
final Script unmountScript = Script.fromLines( final Script unmountScript = Script.fromLines(
"set -x", "set -x",
"gvfs-mount -u \"dav://localhost:$DAV_PORT$DAV_PATH\"") "gvfs-mount -u \"dav:$DAV_SSP\"")
.addEnv("DAV_PORT", String.valueOf(uri.getPort())) .addEnv("DAV_SSP", uri.getRawSchemeSpecificPart());
.addEnv("DAV_PATH", uri.getRawPath());
mountScript.execute(); mountScript.execute();
return new WebDavMount() { return new WebDavMount() {
@Override @Override

View File

@ -31,9 +31,9 @@ final class MacOsXWebDavMounter implements WebDavMounterStrategy {
final String path = "/Volumes/Cryptomator" + uri.getRawPath().replace('/', '_'); final String path = "/Volumes/Cryptomator" + uri.getRawPath().replace('/', '_');
final Script mountScript = Script.fromLines( final Script mountScript = Script.fromLines(
"mkdir \"$MOUNT_PATH\"", "mkdir \"$MOUNT_PATH\"",
"mount_webdav -S -v $MOUNT_NAME \"[::1]:$PORT$DAV_PATH\" \"$MOUNT_PATH\"", "mount_webdav -S -v $MOUNT_NAME \"$DAV_AUTHORITY$DAV_PATH\" \"$MOUNT_PATH\"",
"open \"$MOUNT_PATH\"") "open \"$MOUNT_PATH\"")
.addEnv("PORT", String.valueOf(uri.getPort())) .addEnv("DAV_AUTHORITY", uri.getRawAuthority())
.addEnv("DAV_PATH", uri.getRawPath()) .addEnv("DAV_PATH", uri.getRawPath())
.addEnv("MOUNT_PATH", path) .addEnv("MOUNT_PATH", path)
.addEnv("MOUNT_NAME", name); .addEnv("MOUNT_NAME", name);