hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r738603 - in /hadoop/core/branches/branch-0.20: CHANGES.txt src/core/org/apache/hadoop/fs/Trash.java src/test/org/apache/hadoop/fs/TestTrash.java
Date Wed, 28 Jan 2009 20:18:45 GMT
Author: dhruba
Date: Wed Jan 28 20:18:44 2009
New Revision: 738603

URL: http://svn.apache.org/viewvc?rev=738603&view=rev
Log:
HADOOP-4970. The full path name of a file is preserved inside Trash.
(Prasad Chakka via dhruba)


Modified:
    hadoop/core/branches/branch-0.20/CHANGES.txt   (contents, props changed)
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/Trash.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/TestTrash.java

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=738603&r1=738602&r2=738603&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Wed Jan 28 20:18:44 2009
@@ -64,6 +64,9 @@
 
     HADOOP-4874. Remove LZO codec because of licensing issues. (omalley)
 
+    HADOOP-4970. The full path name of a file is preserved inside Trash.
+    (Prasad Chakka via dhruba)
+
   NEW FEATURES
 
     HADOOP-4575. Add a proxy service for relaying HsftpFileSystem requests.

Propchange: hadoop/core/branches/branch-0.20/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 28 20:18:44 2009
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
-/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732777,732838,732869,733887,734870,734916,735082,736426
+/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732777,732838,732869,733887,734870,734916,735082,736426,738602

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/Trash.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/Trash.java?rev=738603&r1=738602&r2=738603&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/Trash.java (original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/Trash.java Wed Jan 28 20:18:44
2009
@@ -80,6 +80,10 @@
     this.current = new Path(trash, CURRENT);
     this.interval = conf.getLong("fs.trash.interval", 60) * MSECS_PER_MINUTE;
   }
+  
+  private Path makeTrashRelativePath(Path basePath, Path rmFilePath) {
+    return new Path(basePath + rmFilePath.toUri().getPath());
+  }
 
   /** Move a file or directory to the current trash directory.
    * @return false if the item is already in the trash or trash is disabled
@@ -105,19 +109,20 @@
                             "\" to the trash, as it contains the trash");
     }
 
-    Path trashPath = new Path(current, path.getName());
-
+    Path trashPath = makeTrashRelativePath(current, path);
+    Path baseTrashPath = makeTrashRelativePath(current, path.getParent());
+    
     IOException cause = null;
 
     // try twice, in case checkpoint between the mkdirs() & rename()
     for (int i = 0; i < 2; i++) {
       try {
-        if (!fs.mkdirs(current, PERMISSION)) {      // create current
-          LOG.warn("Can't create trash directory: "+current);
+        if (!fs.mkdirs(baseTrashPath, PERMISSION)) {      // create current
+          LOG.warn("Can't create trash directory: "+baseTrashPath);
           return false;
         }
       } catch (IOException e) {
-        LOG.warn("Can't create trash directory: "+current);
+        LOG.warn("Can't create trash directory: "+baseTrashPath);
         return false;
       }
       try {

Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/TestTrash.java?rev=738603&r1=738602&r2=738603&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/fs/TestTrash.java Wed Jan
28 20:18:44 2009
@@ -57,8 +57,8 @@
 
   // check that the specified file is in Trash
   protected static void checkTrash(FileSystem fs, Path trashRoot,
-      String pathname) throws IOException {
-    Path p = new Path(trashRoot+"/"+new Path(pathname).getName());
+      Path path) throws IOException {
+    Path p = new Path(trashRoot+"/"+ path.toUri().getPath());
     assertTrue(fs.exists(p));
   }
 
@@ -106,7 +106,7 @@
     {
       String[] args = new String[2];
       args[0] = "-rm";
-      args[1] = new Path(base, "test/mkdirs/myFile").toString();
+      args[1] = myFile.toString();
       int val = -1;
       try {
         val = shell.run(args);
@@ -117,7 +117,7 @@
       assertTrue(val == 0);
 
       trashRoot = shell.getCurrentTrashDir();
-      checkTrash(fs, trashRoot, args[1]);
+      checkTrash(fs, trashRoot, myFile);
     }
 
     // Verify that we can recreate the file
@@ -216,7 +216,7 @@
     {
       String[] args = new String[2];
       args[0] = "-rm";
-      args[1] = new Path(base, "test/mkdirs/myFile").toString();
+      args[1] = myFile.toString();
       int val = -1;
       try {
         val = shell.run(args);
@@ -225,11 +225,11 @@
                            e.getLocalizedMessage());
       }
       assertTrue(val == 0);
-      checkTrash(fs, trashRoot, args[1]);
+      checkTrash(fs, trashRoot, myFile);
 
       args = new String[2];
       args[0] = "-rmr";
-      args[1] = new Path(base, "test/mkdirs").toString();
+      args[1] = myPath.toString();
       val = -1;
       try {
         val = shell.run(args);
@@ -238,7 +238,7 @@
                            e.getLocalizedMessage());
       }
       assertTrue(val == 0);
-      checkTrash(fs, trashRoot, args[1]);
+      checkTrash(fs, trashRoot, myPath);
     }
 
     // attempt to remove parent of trash
@@ -272,10 +272,10 @@
         f = writeFile(lfs, f);
 
         FileSystem.closeAll();
-        Trash lTrash =
-          new Trash(FileSystem.get(URI.create("file:///"), conf), conf);
+        FileSystem localFs = FileSystem.get(URI.create("file:///"), conf);
+        Trash lTrash = new Trash(localFs, conf);
         lTrash.moveToTrash(f.getParent());
-        assertTrue(lfs.exists(new Path(lTrash.getCurrentTrashDir(), "foo/bar")));
+        checkTrash(localFs, lTrash.getCurrentTrashDir(), f);
       } finally {
         if (lfs.exists(p)) {
           lfs.delete(p, true);



Mime
View raw message