You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ar...@apache.org on 2017/08/21 06:49:51 UTC
hadoop git commit: HDFS-12325. SFTPFileSystem operations should
restore cwd. Contributed by Chen Liang.
Repository: hadoop
Updated Branches:
refs/heads/branch-2 e0ba8a9ed -> d5379cc56
HDFS-12325. SFTPFileSystem operations should restore cwd. Contributed by Chen Liang.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d5379cc5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d5379cc5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d5379cc5
Branch: refs/heads/branch-2
Commit: d5379cc564d58befb1b70b94ac9abfb1a3fbd0f1
Parents: e0ba8a9
Author: Arpit Agarwal <ar...@apache.org>
Authored: Sun Aug 20 23:41:06 2017 -0700
Committer: Arpit Agarwal <ar...@apache.org>
Committed: Sun Aug 20 23:41:16 2017 -0700
----------------------------------------------------------------------
.../main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d5379cc5/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
index 61cdfc4..6986baf 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java
@@ -327,8 +327,10 @@ public class SFTPFileSystem extends FileSystem {
String parentDir = parent.toUri().getPath();
boolean succeeded = true;
try {
+ final String previousCwd = client.pwd();
client.cd(parentDir);
client.mkdir(pathName);
+ client.cd(previousCwd);
} catch (SftpException e) {
throw new IOException(String.format(E_MAKE_DIR_FORPATH, pathName,
parentDir));
@@ -475,8 +477,10 @@ public class SFTPFileSystem extends FileSystem {
}
boolean renamed = true;
try {
+ final String previousCwd = channel.pwd();
channel.cd("/");
channel.rename(src.toUri().getPath(), dst.toUri().getPath());
+ channel.cd(previousCwd);
} catch (SftpException e) {
renamed = false;
}
@@ -559,8 +563,10 @@ public class SFTPFileSystem extends FileSystem {
}
OutputStream os;
try {
+ final String previousCwd = client.pwd();
client.cd(parent.toUri().getPath());
os = client.put(f.getName());
+ client.cd(previousCwd);
} catch (SftpException e) {
throw new IOException(e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org