This is an automated email from the ASF dual-hosted git repository.

motus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/reef.git


The following commit(s) were added to refs/heads/master by this push:
     new d20e391  [REEF-2037] Make local file system deleteDirectory api 
recursive (#1474)
d20e391 is described below

commit d20e391cd9ff0ed522c91ceda0892341e5d596a0
Author: Dwaipayan Mukhopadhyay <[email protected]>
AuthorDate: Wed Jun 20 13:08:15 2018 -0700

    [REEF-2037] Make local file system deleteDirectory api recursive (#1474)
    
    `DeleteDirectory` of `LocalFileSystem` does not do recursive delete unlike 
other filesystem implementations
    
    JIRA:
      [REEF-2037](https://issues.apache.org/jira/browse/REEF-2037)
    
    Pull request:
      This closes [1474](https://github.com/apache/reef/pull/1474)
---
 .../TestLocalFileSystem.cs                         | 27 ++++++++++++++++++++++
 .../FileSystem/Local/LocalFileSystem.cs            |  2 +-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/lang/cs/Org.Apache.REEF.IO.Tests/TestLocalFileSystem.cs 
b/lang/cs/Org.Apache.REEF.IO.Tests/TestLocalFileSystem.cs
index cd17469..6272cb6 100644
--- a/lang/cs/Org.Apache.REEF.IO.Tests/TestLocalFileSystem.cs
+++ b/lang/cs/Org.Apache.REEF.IO.Tests/TestLocalFileSystem.cs
@@ -157,6 +157,33 @@ namespace Org.Apache.REEF.IO.Tests
             fs.DeleteDirectory(directoryUri);
         }
 
+        [Fact]
+        public void TestDeleteDirectory()
+        {
+            var fs = GetFileSystem();
+            // Create directory
+            var directoryUri = new Uri(Path.Combine(Path.GetTempPath(), 
TempFileName) + "/");
+            fs.CreateDirectory(directoryUri);
+
+            // Create sub directory
+            string childDirName = "childDir";
+            var childDirUri = new Uri(directoryUri, childDirName);
+            fs.CreateDirectory(childDirUri);
+
+            // Create file
+            const string fileName = "testfile";
+            var fileUri = new Uri(directoryUri, fileName);
+            MakeRemoteTestFile(fs, fileUri);
+
+            //Create sub directory file      
+            var childDirFileUri = new Uri(directoryUri, 
$"{childDirName}/{fileName}");
+            MakeRemoteTestFile(fs, childDirFileUri);
+
+            fs.DeleteDirectory(directoryUri);
+
+            Assert.False(File.Exists(directoryUri.AbsolutePath));
+        }
+
         private IFileSystem GetFileSystem()
         {
             return TangFactory.GetTang()
diff --git a/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs 
b/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
index 69a33ad..313fdd9 100644
--- a/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
+++ b/lang/cs/Org.Apache.REEF.IO/FileSystem/Local/LocalFileSystem.cs
@@ -107,7 +107,7 @@ namespace Org.Apache.REEF.IO.FileSystem.Local
 
         public void DeleteDirectory(Uri directoryUri)
         {
-            Directory.Delete(directoryUri.LocalPath);
+            Directory.Delete(directoryUri.LocalPath, true);
         }
 
         public IEnumerable<Uri> GetChildren(Uri directoryUri)

Reply via email to