mirror of https://github.com/apache/lucene.git
SOLR-7125: Don't upload dotfiles
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1661506 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bf83ae2a44
commit
1fdf68d482
|
@ -58,6 +58,9 @@ public class ZkConfigManager {
|
||||||
Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>(){
|
Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>(){
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
|
String filename = file.getFileName().toString();
|
||||||
|
if (filename.startsWith("."))
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
String zkNode = zkPath + "/" + rootPath.relativize(file).toString();
|
String zkNode = zkPath + "/" + rootPath.relativize(file).toString();
|
||||||
try {
|
try {
|
||||||
zkClient.makePath(zkNode, file.toFile(), false, true);
|
zkClient.makePath(zkNode, file.toFile(), false, true);
|
||||||
|
@ -67,6 +70,11 @@ public class ZkConfigManager {
|
||||||
}
|
}
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||||
|
return (dir.getFileName().toString().startsWith(".")) ? FileVisitResult.SKIP_SUBTREE : FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@ public class TestZkConfigManager extends SolrTestCaseJ4 {
|
||||||
Files.createFile(tempConfig.resolve("file2"));
|
Files.createFile(tempConfig.resolve("file2"));
|
||||||
Files.createDirectory(tempConfig.resolve("subdir"));
|
Files.createDirectory(tempConfig.resolve("subdir"));
|
||||||
Files.createFile(tempConfig.resolve("subdir").resolve("file3"));
|
Files.createFile(tempConfig.resolve("subdir").resolve("file3"));
|
||||||
|
Files.createFile(tempConfig.resolve(".ignored"));
|
||||||
|
Files.createDirectory(tempConfig.resolve(".ignoreddir"));
|
||||||
|
Files.createFile(tempConfig.resolve(".ignoreddir").resolve("ignored"));
|
||||||
|
|
||||||
configManager.uploadConfigDir(tempConfig, "testconfig");
|
configManager.uploadConfigDir(tempConfig, "testconfig");
|
||||||
|
|
||||||
|
@ -86,6 +89,9 @@ public class TestZkConfigManager extends SolrTestCaseJ4 {
|
||||||
assertTrue(Files.exists(downloadPath.resolve("file2")));
|
assertTrue(Files.exists(downloadPath.resolve("file2")));
|
||||||
assertTrue(Files.isDirectory(downloadPath.resolve("subdir")));
|
assertTrue(Files.isDirectory(downloadPath.resolve("subdir")));
|
||||||
assertTrue(Files.exists(downloadPath.resolve("subdir/file3")));
|
assertTrue(Files.exists(downloadPath.resolve("subdir/file3")));
|
||||||
|
// dotfiles should be ignored
|
||||||
|
assertFalse(Files.exists(downloadPath.resolve(".ignored")));
|
||||||
|
assertFalse(Files.exists(downloadPath.resolve(".ignoreddir/ignored")));
|
||||||
byte[] checkdata = Files.readAllBytes(downloadPath.resolve("file1"));
|
byte[] checkdata = Files.readAllBytes(downloadPath.resolve("file1"));
|
||||||
assertArrayEquals(testdata, checkdata);
|
assertArrayEquals(testdata, checkdata);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue