فهرست منبع

HADOOP-3127. Deleting files in trash should really remove them. Contributed by
Brice Arnould.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@651004 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 سال پیش
والد
کامیت
d3f1803227
3فایلهای تغییر یافته به همراه20 افزوده شده و 2 حذف شده
  1. 3 0
      CHANGES.txt
  2. 1 2
      src/java/org/apache/hadoop/fs/Trash.java
  3. 16 0
      src/test/org/apache/hadoop/dfs/TestTrash.java

+ 3 - 0
CHANGES.txt

@@ -64,6 +64,9 @@ Trunk (unreleased changes)
     HADOOP-3268. file:// URLs issue in TestUrlStreamHandler under Windows.
     (taton)
 
+    HADOOP-3127. Deleting files in trash should really remove them.
+    (Brice Arnould via omalley)
+
 Release 0.17.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 1 - 2
src/java/org/apache/hadoop/fs/Trash.java

@@ -19,7 +19,6 @@ package org.apache.hadoop.fs;
 
 import java.text.*;
 import java.io.*;
-import java.net.URI;
 import java.util.Date;
 
 import org.apache.commons.logging.*;
@@ -85,7 +84,7 @@ public class Trash extends Configured {
     if (!fs.exists(path))                         // check that path exists
       throw new FileNotFoundException(path.toString());
 
-    if (path.toString().startsWith(trash.toString())) {
+    if (path.makeQualified(fs).toString().startsWith(trash.toString())) {
       return false;                               // already in trash
     }
 

+ 16 - 0
src/test/org/apache/hadoop/dfs/TestTrash.java

@@ -174,6 +174,22 @@ public class TestTrash extends TestCase {
         assertTrue(val == 0);
       }
 
+      // Check that we can delete a file from the trash
+      {
+          Path toErase = new Path(trashRoot, "toErase");
+          int retVal = -1;
+          writeFile(fs, toErase);
+          try {
+            retVal = shell.run(new String[] {"-rm", toErase.toString()});
+          } catch (Exception e) {
+            System.err.println("Exception raised from Trash.run " +
+                               e.getLocalizedMessage()); 
+          }
+          assertTrue(retVal == 0);
+          checkNotInTrash (fs, trashRoot, toErase.toString());
+          checkNotInTrash (fs, trashRoot, toErase.toString()+".1");
+      }
+
       // simulate Trash removal
       {
         String[] args = new String[1];