hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r448378 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/DFSShell.java
Date Wed, 20 Sep 2006 22:33:05 GMT
Author: cutting
Date: Wed Sep 20 15:33:05 2006
New Revision: 448378

URL: http://svn.apache.org/viewvc?view=rev&rev=448378
Log:
HADOOP-431.  Change 'dfs -rm' to not operate recursively and add a new command, 'dfs -rmr',
that operates recursively.  Contributed by Sameer.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=448378&r1=448377&r2=448378
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Sep 20 15:33:05 2006
@@ -51,6 +51,10 @@
     modifications are permitted and block replication is inhibited.
     (Konstantin Shvachko via cutting)
 
+14. HADOOP-431.  Change 'dfs -rm' to not operate recursively and add a
+    new command, 'dfs -rmr' which operates recursively.
+    (Sameer Paranjpye via cutting)
+
 
 Release 0.6.2 (unreleased)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java?view=diff&rev=448378&r1=448377&r2=448378
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSShell.java Wed Sep 20 15:33:05 2006
@@ -255,12 +255,19 @@
     /**
      * Delete an DFS file
      */
-    public void delete(String srcf) throws IOException {
-        if (fs.delete(new Path(srcf))) {
-            System.out.println("Deleted " + srcf);
-        } else {
-            System.out.println("Delete failed");
-        }
+    public void delete(String srcf, boolean recursive) throws IOException {
+      Path srcp = new Path(srcf);
+      if (fs.isDirectory(srcp) && !recursive) {
+        System.out.println("Cannot remove directory \"" + srcf +
+                           "\", use -rmr instead");
+        return;
+      }
+
+      if (fs.delete(srcp)) {
+        System.out.println("Deleted " + srcf);
+      } else {
+        System.out.println("Delete failed");
+      }
     }
 
     /**
@@ -367,7 +374,8 @@
                 " [-du <path>]"+
                 " [-mv <src> <dst>]"+
                 " [-cp <src> <dst>]"+
-                " [-rm <src>]" +
+                " [-rm <path>]" +
+                " [-rmr <path>]" +
                 " [-put <localsrc> <dst>]"+
                 " [-copyFromLocal <localsrc> <dst>]"+
                 " [-moveFromLocal <localsrc> <dst>]" + 
@@ -419,7 +427,9 @@
             } else if ("-cp".equals(cmd)) {
                 copy(argv[i++], argv[i++], conf);
             } else if ("-rm".equals(cmd)) {
-                delete(argv[i++]);
+                delete(argv[i++], false);
+            } else if ("-rmr".equals(cmd)) {
+                delete(argv[i++], true);
             } else if ("-du".equals(cmd)) {
                 String arg = i < argv.length ? argv[i++] : "";
                 du(arg);



Mime
View raw message