Reverting commit 296848b41e, reopen #542

This commit is contained in:
Sebastian Stenzel
2017-11-23 12:47:41 +01:00
parent f84760746f
commit b64f7cc7a8
3 changed files with 1 additions and 67 deletions

View File

@@ -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()) {

View File

@@ -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;
}
}
}

View File

@@ -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));
}
}