Pārlūkot izejas kodu

HADOOP-865. Fix S3 FileSystem so that partially created files can be deleted. Contributed by Tom White.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@494604 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 gadi atpakaļ
vecāks
revīzija
892bc5a46d

+ 3 - 0
CHANGES.txt

@@ -26,6 +26,9 @@ Trunk (unreleased changes)
  8. HADOOP-868.  Decrease the number of open files during map,
     respecting io.sort.factor.  (Devaraj Das via cutting)
 
+ 9. HADOOP-865.  Fix S3 FileSystem so that partially created files can
+    be deleted.  (Tom White via cutting)
+
 
 Release 0.10.0 - 2007-01-05
 

+ 1 - 1
src/java/org/apache/hadoop/fs/s3/S3FileSystem.java

@@ -192,7 +192,7 @@ public class S3FileSystem extends FileSystem {
     Path absolutePath = makeAbsolute(path);
     INode inode = store.getINode(absolutePath);
     if (inode == null) {
-      throw new IOException("No such file or directory.");
+      return false;
     }
     store.deleteINode(absolutePath);
     if (inode.isFile()) {

+ 6 - 1
src/test/org/apache/hadoop/fs/s3/S3FileSystemBaseTest.java

@@ -199,7 +199,12 @@ public abstract class S3FileSystemBaseTest extends TestCase {
     assertEquals("Length", BLOCK_SIZE, s3FileSystem.getLength(path));
     assertTrue("Parent exists", s3FileSystem.exists(path.getParent()));
   }
-
+  
+  public void testDeleteNonExistentFile() throws IOException {
+    Path path = new Path("/test/hadoop/file");    
+    assertFalse("Doesn't exist", s3FileSystem.exists(path));
+    assertFalse("No deletion", s3FileSystem.delete(path));
+  }
 
   public void testRename() throws Exception {
     int len = BLOCK_SIZE;