hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r641466 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/util/CopyFiles.java
Date Wed, 26 Mar 2008 18:39:57 GMT
Author: omalley
Date: Wed Mar 26 11:39:55 2008
New Revision: 641466

URL: http://svn.apache.org/viewvc?rev=641466&view=rev
Log:
HADOOP-3056. Fix distcp when the target is an empty directory by
making sure the directory is created first. Contributed by cdouglas and 
acmurthy.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/util/CopyFiles.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=641466&r1=641465&r2=641466&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Mar 26 11:39:55 2008
@@ -403,6 +403,10 @@
     HADOOP-3027. Fixes a problem to do with adding a shutdown hook in
     FileSystem.  (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-3056. Fix distcp when the target is an empty directory by
+    making sure the directory is created first. (cdouglas and acmurthy 
+    via omalley)
+
 Release 0.16.1 - 2008-03-13
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/util/CopyFiles.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/util/CopyFiles.java?rev=641466&r1=641465&r2=641466&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/util/CopyFiles.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/util/CopyFiles.java Wed Mar 26 11:39:55 2008
@@ -142,6 +142,9 @@
       input.write(out);
       Text.writeString(out, output.toString());
     }
+    public String toString() {
+      return input.toString() + " : " + output.toString();
+    }
   }
 
   /**
@@ -344,6 +347,9 @@
             destFileSys.getFileStatus(absdst).isDir()) {
           throw new IOException(absdst + " is a directory");
         }
+        if (!destFileSys.mkdirs(absdst.getParent())) {
+          throw new IOException("Failed to craete parent dir: " + absdst.getParent());
+        }
         rename(destFileSys, tmpfile, absdst);
       }
 
@@ -360,7 +366,9 @@
         if (fs.exists(dst)) {
           fs.delete(dst, true);
         }
-        fs.rename(tmp, dst);
+        if (!fs.rename(tmp, dst)) {
+          throw new IOException();
+        }
       }
       catch(IOException cause) {
         IOException ioe = new IOException("Fail to rename tmp file (=" + tmp 



Mime
View raw message