reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (REEF-2036) IFileSystem api to check if uri is for a directory
Date Wed, 13 Jun 2018 20:10:00 GMT

    [ https://issues.apache.org/jira/browse/REEF-2036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16511607#comment-16511607
] 

ASF GitHub Bot commented on REEF-2036:
--------------------------------------

tyclintw commented on a change in pull request #1473: [REEF-2036] Add IFileSystem api to check
if uri is a directory
URL: https://github.com/apache/reef/pull/1473#discussion_r195218460
 
 

 ##########
 File path: lang/cs/Org.Apache.REEF.IO.Tests/TestHadoopFileSystem.cs
 ##########
 @@ -128,24 +129,44 @@ public void TestGetChildren()
             _fileSystem.DeleteDirectory(remoteDirectory);
         }
 
-        [Fact(Skip = "These tests need to be run in an environment with HDFS installed.")]
+        [Fact(Skip = SkipMessage)]
         public void TestOpen()
         {
             // Open() is not supported by HadoopFileSystem. Use CopyToLocal and open the
local file instead.
             Assert.Throws<NotImplementedException>(() => _fileSystem.Open(GetTempUri()));
         }
 
-        [Fact(Skip = "These tests need to be run in an environment with HDFS installed.")]
+        [Fact(Skip = SkipMessage)]
         public void TestCreate()
         {
             // Create() is not supported by HadoopFileSystem. Create a local file and use
CopyFromLocal instead.
             Assert.Throws<NotImplementedException>(() => _fileSystem.Create(GetTempUri()));
         }
 
+        /// <summary>
+        /// Tests whether .IsDirectory() works.
+        /// </summary>
+        [Fact(Skip = SkipMessage)]
+        public void TestIsDirectory()
+        {
+            var remoteDirUri = GetTempUri();
+            _fileSystem.CreateDirectory(remoteDirUri);
+            var remoteFakeuri = GetTempUri();
+            var remoteFileUri = GetTempUri();
+            var localFile = FileSystemTestUtilities.MakeLocalTempFile();
+            _fileSystem.CopyFromLocal(localFile, remoteFileUri);
+            Assert.True(_fileSystem.IsDirectory(remoteDirUri));
+            Assert.False(_fileSystem.IsDirectory(remoteFakeuri));
+            Assert.False(_fileSystem.IsDirectory(remoteFileUri));
+            _fileSystem.DeleteDirectory(remoteDirUri);
+            _fileSystem.Delete(remoteFileUri);
+            File.Delete(localFile);
 
 Review comment:
   Agreed, but please avoid in the future if possible. Please break up this code block for
readability as well.
   
   ---
   In reply to: [194580410](https://github.com/apache/reef/pull/1473#discussion_r194580410)
[](ancestors = 194580410,194556624)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> IFileSystem api to check if uri is for a directory
> --------------------------------------------------
>
>                 Key: REEF-2036
>                 URL: https://issues.apache.org/jira/browse/REEF-2036
>             Project: REEF
>          Issue Type: New Feature
>          Components: REEF
>            Reporter: Dwaipayan Mukhopadhyay
>            Assignee: Dwaipayan Mukhopadhyay
>            Priority: Major
>
> Currently, there is no way to check if a location specified by a uri is a directory
or not. The only way to check it is by calling fs.GetChildren and checking for an exception.
There should be a more graceful way of doing this check by adding an api.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message