Browse Source

Reverting commit 296848b41e544645076b6c2f8b7f3eeea82b2c29, reopen #542

Sebastian Stenzel 7 years ago
parent
commit
b64f7cc7a8

+ 1 - 3
main/ui/src/main/java/org/cryptomator/ui/controllers/MainController.java

@@ -16,7 +16,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,7 +41,6 @@ import org.cryptomator.ui.model.VaultFactory;
 import org.cryptomator.ui.model.VaultList;
 import org.cryptomator.ui.util.DialogBuilderUtil;
 import org.cryptomator.ui.util.EawtApplicationWrapper;
-import org.cryptomator.ui.util.ProcessFilePath;
 import org.fxmisc.easybind.EasyBind;
 import org.fxmisc.easybind.Subscription;
 import org.fxmisc.easybind.monadic.MonadicBinding;
@@ -265,7 +263,7 @@ public class MainController implements ViewController {
 			return;
 		}
 		try {
-			final Path vaultDir = Paths.get(ProcessFilePath.processFilePath(file.getPath()));
+			final Path vaultDir = file.toPath();
 			if (Files.exists(vaultDir)) {
 				try (Stream<Path> stream = Files.list(vaultDir)) {
 					if (stream.filter(this::isNotHidden).findAny().isPresent()) {

+ 0 - 27
main/ui/src/main/java/org/cryptomator/ui/util/ProcessFilePath.java

@@ -1,27 +0,0 @@
-package org.cryptomator.ui.util;
-
-import java.io.File;
-
-/**
- * Class for processing a file path.
- * If the filepath is a UNC file path (syntax: \\server[@SSL][@port][\path]), the "@SSL" and "@port" part is ripped off.
- */
-public class ProcessFilePath {
-
-	public static String processFilePath(String path) {
-		int uncIndex = path.indexOf('@');
-		int resourceIndex = path.indexOf('\\', 2);
-		if (System.getProperty("os.name").contains("Windows") && path.startsWith("\\\\") && uncIndex >= 0 && (resourceIndex == -1 || uncIndex < resourceIndex)) {
-			//the returned file has a UNC-Path, which needs further processing
-			if (resourceIndex >= 0) {
-				//the optional path part exists, therefore we cut everything else out
-				return path.substring(0, uncIndex).concat(path.substring(resourceIndex));
-			} else {
-				return path.substring(0, uncIndex);
-			}
-		} else {
-			return path;
-		}
-	}
-
-}

+ 0 - 37
main/ui/src/test/java/org/cryptomator/ui/util/ProcessFilePathsTest.java

@@ -1,37 +0,0 @@
-package org.cryptomator.ui.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ProcessFilePathsTest {
-
-	@Test
-	public void testSavedFilePathAtVaultCreation() {
-		String uncBase = "\\\\server";
-		String uncSSL = "@SSL";
-		String port = "@1234";
-		String path = "\\@test@Dir\\test@File.test";
-		String driveLetter = "C:";
-		String uncWithSSL = uncBase.concat(uncSSL);
-		String uncWithPort = uncBase.concat(port);
-		String uncWithPath = uncBase.concat(path);
-		String uncWithSSLAndPath = uncWithSSL.concat(path);
-		String uncWithPortAndPath = uncWithPort.concat(path);
-		String uncWithSSLAndPort = uncWithSSL.concat(port);
-		String uncWithSSLAndPortAndPath = uncWithSSLAndPort.concat(path);
-		String pathWithDriveLetter = driveLetter.concat(path);
-		String uriWithUserinfo = "file:\\\\userinfo@server\\test@dir";
-
-		Assert.assertEquals(uncBase, ProcessFilePath.processFilePath(uncBase));
-		Assert.assertEquals(path, ProcessFilePath.processFilePath(path));
-		Assert.assertEquals(uncBase, ProcessFilePath.processFilePath(uncWithSSL));
-		Assert.assertEquals(uncBase, ProcessFilePath.processFilePath(uncWithPort));
-		Assert.assertEquals(uncBase, ProcessFilePath.processFilePath(uncWithSSLAndPort));
-		Assert.assertEquals(uncWithPath, ProcessFilePath.processFilePath(uncWithPath));
-		Assert.assertEquals(uncWithPath, ProcessFilePath.processFilePath(uncWithSSLAndPath));
-		Assert.assertEquals(uncWithPath, ProcessFilePath.processFilePath(uncWithPortAndPath));
-		Assert.assertEquals(uncWithPath, ProcessFilePath.processFilePath(uncWithSSLAndPortAndPath));
-		Assert.assertEquals(pathWithDriveLetter, ProcessFilePath.processFilePath(pathWithDriveLetter));
-		Assert.assertEquals(uriWithUserinfo, ProcessFilePath.processFilePath(uriWithUserinfo));
-	}
-}