hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r793987 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FsShell.java
Date Tue, 14 Jul 2009 17:39:34 GMT
Author: szetszwo
Date: Tue Jul 14 17:39:33 2009
New Revision: 793987

URL: http://svn.apache.org/viewvc?rev=793987&view=rev
Log:
HADOOP-6145. Fix FsShell rm/rmr error messages when there is a FNFE.  Contributed by Jakob
Homan

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=793987&r1=793986&r2=793987&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Jul 14 17:39:33 2009
@@ -1014,6 +1014,9 @@
     HADOOP-6139. Fix the FsShell help messages for rm and rmr.  (Jakob Homan
     via szetszwo)
 
+    HADOOP-6145. Fix FsShell rm/rmr error messages when there is a FNFE.
+    (Jakob Homan via szetszwo)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=793987&r1=793986&r2=793987&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FsShell.java Tue Jul 14 17:39:33 2009
@@ -1110,7 +1110,16 @@
   /* delete a file */
   private void delete(Path src, FileSystem srcFs, boolean recursive, 
                       boolean skipTrash) throws IOException {
-    if (srcFs.isDirectory(src) && !recursive) {
+    FileStatus fs = null;
+    try {
+      fs = srcFs.getFileStatus(src);
+    } catch (FileNotFoundException fnfe) {
+      // Have to re-throw so that console output is as expected
+      throw new FileNotFoundException("cannot remove "
+          + src + ": No such file or directory.");
+    }
+    
+    if (fs.isDir() && !recursive) {
       throw new IOException("Cannot remove directory \"" + src +
                             "\", use -rmr instead");
     }
@@ -1126,10 +1135,6 @@
     if (srcFs.delete(src, true)) {
       System.out.println("Deleted " + src);
     } else {
-      if (!srcFs.exists(src)) {
-        throw new FileNotFoundException("cannot remove "
-            + src + ": No such file or directory.");
-        }
       throw new IOException("Delete failed " + src);
     }
   }



Mime
View raw message