attempt to fix socket on Windows

This commit is contained in:
Sebastian Stenzel
2021-07-14 12:45:09 +02:00
parent e9461b4fc7
commit c10a909ea4
2 changed files with 4 additions and 2 deletions

View File

@@ -6,7 +6,9 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.UnixDomainSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.Executor;
class Client implements IpcCommunicator {
@@ -20,6 +22,8 @@ class Client implements IpcCommunicator {
}
public static Client create(Path socketPath) throws IOException {
// fail with NoSuchFileException early to prevent implicit creation of socket on Windows:
socketPath.getFileSystem().provider().checkAccess(socketPath);
var address = UnixDomainSocketAddress.of(socketPath);
var socketChannel = SocketChannel.open(address);
LOG.info("Connected to IPC server on UNIX socket {}", socketPath);

View File

@@ -1,11 +1,9 @@
package org.cryptomator.ipc;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mockito;
import java.io.IOException;
import java.nio.file.Path;