You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2018/11/21 09:57:14 UTC

[GitHub] arina-ielchiieva commented on a change in pull request #1547: DRILL-6858: Add functionality to list directories / files with exceptions suppression

arina-ielchiieva commented on a change in pull request #1547: DRILL-6858: Add functionality to list directories / files with exceptions suppression
URL: https://github.com/apache/drill/pull/1547#discussion_r235319710
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/util/FileSystemUtil.java
 ##########
 @@ -55,7 +53,28 @@ public boolean accept(Path path) {
    */
   public static List<FileStatus> listDirectories(final FileSystem fs, Path path, boolean recursive, PathFilter... filters) throws IOException {
     List<FileStatus> statuses = new ArrayList<>();
-    listDirectories(fs, path, recursive, statuses, mergeFilters(filters));
+    listDirectories(fs, path, recursive, false, statuses, mergeFilters(filters));
+    return statuses;
+  }
+
+  /**
+   * Returns statuses of all directories present in given path applying custom filters if present.
+   * Will also include nested directories if recursive flag is set to true.
+   * Will ignore all exceptions during listing if any.
+   *
+   * @param fs current file system
+   * @param path path to directory
+   * @param recursive true if nested directories should be included
+   * @param filters list of custom filters (optional)
+   * @return list of matching directory statuses
+   */
+  public static List<FileStatus> listDirectoriesSafe(final FileSystem fs, Path path, boolean recursive, PathFilter... filters) {
+    List<FileStatus> statuses = new ArrayList<>();
+    try {
+      listDirectories(fs, path, recursive, false, statuses, mergeFilters(filters));
 
 Review comment:
   Good catch, thanks!

----------------------------------------------------------------
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


With regards,
Apache Git Services