Selaa lähdekoodia

HADOOP-1599. Fix distcp on Windows. Contributed by Senthil.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@556687 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 vuotta sitten
vanhempi
commit
4021462d96

+ 2 - 0
CHANGES.txt

@@ -354,6 +354,8 @@ Trunk (unreleased changes)
 110. HADOOP-1524.  Permit user task logs to appear as they're
      created.  (Michael Bieniosek via cutting)
 
+111. HADOOP-1599.  Fix distcp bug on Windows.  (Senthil Subramanian via cutting)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 3 - 3
src/java/org/apache/hadoop/util/CopyFiles.java

@@ -805,7 +805,7 @@ public class CopyFiles extends ToolBase {
       } else if (destPath == null) {
         destPath = args[idx];
       } else if ("-log".equals(args[idx])) {
-        logPath = new Path(args[++idx]);
+        logPath = new Path(toURI(args[++idx]).getPath());
       } else {
         System.out.println(usage);
         return -1;
@@ -829,14 +829,14 @@ public class CopyFiles extends ToolBase {
     try {
       URI srcURI = toURI(srcPath);
       FileSystem srcfs = FileSystem.get(srcURI, conf);
-      if (!srcfs.exists(new Path(srcPath))) {
+      if (!srcfs.exists(new Path(srcURI.getPath()))) {
         System.out.println(srcPath + " does not exist.");
         return -1;
       }
 
       URI destURI = toURI(destPath);
       FileSystem destfs = FileSystem.get(destURI, conf);
-      if (destfs.exists(new Path(destPath))) {
+      if (destfs.exists(new Path(destURI.getPath()))) {
         System.out.println("WARNING: " + destPath + " already exists.");
       }
 

+ 3 - 3
src/test/org/apache/hadoop/fs/TestCopyFiles.java

@@ -241,14 +241,14 @@ public class TestCopyFiles extends TestCase {
         new CopyFiles().doMain(conf, new String[] {"hdfs://"+namenode+"/srcdat",
                                                    "file://"+TEST_ROOT_DIR+"/destdat",
                                                    "-log",
-                                                   TEST_ROOT_DIR+"/logs"});
+                                                   "/logs"});
         assertTrue("Source and destination directories do not match.",
                    checkFiles("local", TEST_ROOT_DIR+"/destdat", files));
         FileSystem fs = FileSystem.get(URI.create("hdfs://"+namenode+"/logs"), conf);
         assertTrue("Log directory doesnot exist.",
-                    fs.exists(new Path(TEST_ROOT_DIR+"/logs")));
+                    fs.exists(new Path("/logs")));
         deldir("local", TEST_ROOT_DIR+"/destdat");
-        deldir("local", TEST_ROOT_DIR+"/logs");
+        deldir(namenode, "/logs");
         deldir(namenode, "/srcdat");
       }
     } finally {