ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-3638: Implemented rename.
Date Tue, 09 Aug 2016 07:20:15 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1926 1b67b9ce6 -> 427955bac


IGNITE-3638: Implemented rename.


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

Branch: refs/heads/ignite-1926
Commit: 427955bac52e2c6cedb5fa7eb429c14c503855e3
Parents: 1b67b9c
Author: tledkov-gridgain <tledkov@gridgain.com>
Authored: Tue Aug 9 10:20:03 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Aug 9 10:20:03 2016 +0300

----------------------------------------------------------------------
 .../hadoop/fs/LocalIgfsSecondaryFileSystem.java   | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/427955ba/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 1166564..537b2a4 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
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.hadoop.fs;
 
+import java.nio.file.Files;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.ParentNotDirectoryException;
@@ -202,15 +203,24 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem,
Li
 
     /** {@inheritDoc} */
     @Override public void rename(IgfsPath src, IgfsPath dest) {
-        // TODO: IGNITE-3638.
-        // Delegate to the secondary file system.
         try {
-            if (!fileSystemForUser().rename(convert(src), convert(dest)))
+            File srcFile = fileForPath(src);
+            File destFile = fileForPath(dest);
+
+            if (!srcFile.exists())
+                throw new IOException("File not found: " + srcFile);
+
+            if (srcFile.isDirectory() && destFile.isFile())
+                throw new IOException("Failed rename directory to existing file: [src=" +
src + ", dest=" + dest + ']');
+
+            if (destFile.isDirectory())
+                Files.move(srcFile.toPath(), destFile.toPath().resolve(srcFile.getName()));
+            else if(!srcFile.renameTo(destFile))
                 throw new IgfsException("Failed to rename (secondary file system returned
false) " +
                     "[src=" + src + ", dest=" + dest + ']');
         }
         catch (IOException e) {
-            throw handleSecondaryFsError(e, "Failed to rename file [src=" + src + ", dest="
+ dest + ']');
+            throw handleSecondaryFsError(e, "Failed to rename [src=" + src + ", dest="+ dest
+ ']');
         }
     }
 


Mime
View raw message