From 2d1c5924e54f556642b92ec702cdbee071db3e75 Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Fri, 4 Mar 2005 22:31:40 +0000 Subject: [PATCH] PR: 33770 Improved FTP task to not fail on hidden directories. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277793 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/OptionalTasks/ftp.html | 4 ++- .../tools/ant/taskdefs/optional/net/FTP.java | 35 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/manual/OptionalTasks/ftp.html b/docs/manual/OptionalTasks/ftp.html index 2e57612de..4ed423ca7 100644 --- a/docs/manual/OptionalTasks/ftp.html +++ b/docs/manual/OptionalTasks/ftp.html @@ -262,11 +262,13 @@ patterns of the fileset
href="../CoreTypes/fileset.html"><fileset> elements to specify the files to be retrieved, or deleted, or listed, or whose mode you want to change.

-The attribute followsymlinks of fileset is fully supported on +The attribute followsymlinks of fileset is supported on local (put) as well as remote (get, chmod, delete) filesets. Before ant 1.6 there was no support of symbolic links in remote filesets. In order to exclude symbolic links (preserve the behavior of ant 1.5.x and older), you need to explicitly set followsymlinks to false. +On remote filesets hidden files are not checked for being symbolic links. Hidden +files are currently assumed to not be symbolic links.

Remote filesets do not support selectors.
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 0db993491..31e718e38 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 @@ -194,7 +194,8 @@ public class FTP try { String cwd = ftp.printWorkingDirectory(); // always start from the current ftp working dir - + forceRemoteSensitivityCheck(); + checkIncludePatterns(); clearCaches(); ftp.changeWorkingDirectory(cwd); @@ -210,6 +211,7 @@ public class FTP * @since ant1.6 */ private void checkIncludePatterns() { + Hashtable newroots = new Hashtable(); // put in the newroots vector the include patterns without // wildcard tokens @@ -246,6 +248,7 @@ public class FTP String path = null; if (myfile.exists()) { + forceRemoteSensitivityCheck(); if (remoteSensitivityChecked && remoteSystemCaseSensitive && isFollowSymlinks()) { // cool case, @@ -262,7 +265,6 @@ public class FTP throw new BuildException(be, getLocation()); } catch (BuildException be) { isOK = false; - } } } else { @@ -509,6 +511,17 @@ public class FTP } return result; } + + private void forceRemoteSensitivityCheck() + { + if (!remoteSensitivityChecked) { + try { + checkRemoteSensitivity(ftp.listFiles(), ftp.printWorkingDirectory()); + } catch (IOException ioe) { + throw new BuildException(ioe, getLocation()); + } + } + } /** * cd into one directory and * list the files present in one directory. @@ -763,14 +776,16 @@ public class FTP if (theFiles != null) { theFile = getFile(theFiles, currentElement); } + if (!relPath.equals("")) { + relPath = relPath + remoteFileSep; + } if (theFile == null) { - throw new BuildException("could not find " + currentElement - + " from " + currentPath); + // hit a hidden file assume not a symlink + relPath = relPath + currentElement; + currentPath = currentPath + remoteFileSep + currentElement; + log("Hidden file " + relPath + " assumed to not be a symlink.", Project.MSG_VERBOSE); } else { traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink(); - if (!relPath.equals("")) { - relPath = relPath + remoteFileSep; - } relPath = relPath + theFile.getName(); currentPath = currentPath + remoteFileSep + theFile.getName(); } @@ -854,6 +869,10 @@ public class FTP } return traversesSymlinks; } + + public String toString() { + return "AntFtpFile: "+curpwd+"%"+ftpFile; + } } /** * special class to represent the remote directory itself @@ -1273,7 +1292,6 @@ public class FTP protected int transferFiles(FTPClient ftp, FileSet fs) throws IOException, BuildException { DirectoryScanner ds; - if (action == SEND_FILES) { ds = fs.getDirectoryScanner(getProject()); } else { @@ -1771,7 +1789,6 @@ public class FTP protected void getFile(FTPClient ftp, String dir, String filename) throws IOException, BuildException { OutputStream outstream = null; - try { File file = getProject().resolveFile(new File(dir, filename).getPath());