You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/08/08 10:40:27 UTC
[4/4] ignite git commit: TODOs.
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 <vo...@gridgain.com>
Authored: Mon Aug 8 13:40:03 2016 +0300
Committer: vozerov-gridgain <vo...@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.