Skip to content

Apache Lucene open-source search software

SOLR-7158: Fix zk upload on Windows systems

Alan Woodward8e0ce8dd0ba6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ace44bc5ed6..43357bc7e3c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -112,8 +112,8 @@ New Features
* SOLR-1945: Add support for child docs in DocumentObjectBinder (Noble Paul, Mark Miller)
-* SOLR-7125: You can upload and download configurations via CloudSolrClient
- (Alan Woodward)
+* SOLR-7125, SOLR-7158: You can upload and download configurations via CloudSolrClient
+ (Alan Woodward, Ishan Chattopadhyaya)
* SOLR-5507: Admin UI - Refactoring using AngularJS, first part (Upayavira via
Erick Erickson)
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
index d11aac19e68..a3a806099e5 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java
@@ -61,7 +61,7 @@ public class ZkConfigManager {
String filename = file.getFileName().toString();
if (filename.startsWith("."))
return FileVisitResult.CONTINUE;
- String zkNode = zkPath + "/" + rootPath.relativize(file).toString();
+ String zkNode = createZkNodeName(zkPath, rootPath, file);
try {
zkClient.makePath(zkNode, file.toFile(), false, true);
} catch (KeeperException | InterruptedException e) {
@@ -78,6 +78,15 @@ public class ZkConfigManager {
});
}
+ private static String createZkNodeName(String zkRoot, Path root, Path file) {
+ String relativePath = root.relativize(file).toString();
+ // Windows shenanigans
+ String separator = root.getFileSystem().getSeparator();
+ if ("\\".equals(separator))
+ relativePath = relativePath.replaceAll("\\\\", "/");
+ return zkRoot + "/" + relativePath;
+ }
+
private void downloadFromZK(String zkPath, Path dir) throws IOException {
try {
List<String> files = zkClient.getChildren(zkPath, null, true);