Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 86967 invoked from network); 26 Mar 2008 18:40:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Mar 2008 18:40:21 -0000 Received: (qmail 16453 invoked by uid 500); 26 Mar 2008 18:40:20 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 16328 invoked by uid 500); 26 Mar 2008 18:40:20 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 16318 invoked by uid 99); 26 Mar 2008 18:40:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 11:40:20 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 18:39:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F122F1A9838; Wed, 26 Mar 2008 11:39:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: core-commits@hadoop.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080326183959.F122F1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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