ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [4/4] ignite git commit: TODOs.
Date Mon, 08 Aug 2016 10:40:27 GMT
TODOs.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b7e2a335
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b7e2a335
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b7e2a335

Branch: refs/heads/ignite-1926
Commit: b7e2a33570185f7e39c23c57743e7b014c4039bd
Parents: 2f95ce8
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Aug 8 13:40:03 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Aug 8 13:40:03 2016 +0300

----------------------------------------------------------------------
 .../hadoop/fs/LocalIgfsSecondaryFileSystem.java | 62 +++++++++++---------
 1 file changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b7e2a335/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/LocalIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/LocalIgfsSecondaryFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/LocalIgfsSecondaryFileSystem.java
index aff80c8..f89ba69 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/LocalIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/LocalIgfsSecondaryFileSystem.java
@@ -212,19 +212,52 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem,
Li
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("ConstantConditions")
     @Override public boolean delete(IgfsPath path, boolean recursive) {
         try {
             File f = fileForPath(path);
+
+            // TODO: IGNITE-3642.
             if (!recursive || !f.isDirectory())
                 return f.delete();
             else
-                return deleteDir(f);
+                return deleteDirectory(f);
         }
         catch (IOException e) {
             throw handleSecondaryFsError(e, "Failed to delete file [path=" + path + ", recursive="
+ recursive + "]");
         }
     }
 
+    /**
+     * Delete directory recursively.
+     *
+     * @param dir Directory.
+     * @throws IOException If fails.
+     * @return {@code true} if successful.
+     */
+    private boolean deleteDirectory(File dir) throws IOException {
+        File[] entries = dir.listFiles();
+
+        if (entries != null) {
+            for (File entry : entries) {
+                if (entry.isDirectory())
+                    deleteDirectory(entry);
+                else if (entry.isFile()) {
+                    if (!entry.delete())
+                        throw new IOException("Cannot remove file: " + entry);
+                }
+                else
+                    // TODO: IGNITE-3642.
+                    throw new UnsupportedOperationException("Symlink deletion is not supported:
" + entry);
+            }
+        }
+
+        if (!dir.delete())
+            throw new IOException("Cannot remove directory: " + dir);
+
+        return true;
+    }
+
     /** {@inheritDoc} */
     @Override public void mkdirs(IgfsPath path) {
         if (!mkdirs0(fileForPath(path)))
@@ -553,33 +586,6 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem,
Li
     }
 
     /**
-     * @param dir Directory.
-     * @throws IOException If fails.
-     * @return {@code true} if successful.
-     */
-    private boolean deleteDir(File dir) throws IOException {
-        File[] dirEntries = dir.listFiles();
-
-        if (dirEntries != null) {
-            for (int i = 0; i < dirEntries.length; ++i) {
-                File f = dirEntries[i];
-
-                if (!f.isDirectory()) { // TODO: should we support symlink?
-                    if (!f.delete())
-                        throw new IOException("Cannot remove [file=" + f + ']');
-                }
-                else
-                    deleteDir(dirEntries[i]);
-            }
-        }
-
-        if (!dir.delete())
-            throw new IOException("Cannot remove [dir=" + dir + ']');
-
-        return true;
-    }
-
-    /**
      * Internal create routine.
      *
      * @param path Path.


Mime
View raw message