From 92663dfd6a98615bd2d2b087f988561ff35102af Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 17 May 2010 09:17:19 +0000 Subject: [PATCH] ftp download fails for certain setups. PR 49296. Based on patch by Kristof Neirynck git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@945039 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ .../tools/ant/taskdefs/optional/net/FTP.java | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 1ffa4f18f..28234e67c 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -30,6 +30,10 @@ Fixed bugs: name didn't occur inside more than one directory. Bugzilla Report 36748. + * could fail to download files from remote subdirectories under + certain circumstances. + Bugzilla Report 49296. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index ee6518d45..67e5e6606 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -834,7 +834,7 @@ public class FTP extends Task implements FTPTaskConfig { } else if (!result) { return; } - this.curpwd = this.curpwd + remoteFileSep + this.curpwd = getCurpwdPlusFileSep() + currentPathElement; } catch (IOException ioe) { throw new BuildException("could not change working dir to " @@ -895,7 +895,7 @@ public class FTP extends Task implements FTPTaskConfig { * @return absolute path as string */ public String getAbsolutePath() { - return curpwd + remoteFileSep + ftpFile.getName(); + return getCurpwdPlusFileSep() + ftpFile.getName(); } /** * find out the relative path assuming that the path used to construct @@ -1036,6 +1036,17 @@ public class FTP extends Task implements FTPTaskConfig { public String getCurpwd() { return curpwd; } + /** + * returns the path of the directory containing the AntFTPFile. + * of the full path of the file itself in case of AntFTPRootFile + * and appends the remote file separator if necessary. + * @return parent directory of the AntFTPFile + * @since Ant 1.8.2 + */ + public String getCurpwdPlusFileSep() { + return curpwd.endsWith(remoteFileSep) ? curpwd + : curpwd + remoteFileSep; + } /** * find out if a symbolic link is encountered in the relative path of this file * from rootPath.