antoine 2003/08/14 07:47:54 Modified: src/main/org/apache/tools/ant/types AbstractFileSet.java src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java src/testcases/org/apache/tools/ant/taskdefs/optional/net FTPTest.java src/etc/testcases/taskdefs/optional/net ftp.xml Log: Go on working on the followsymlinks support in the FTP task. The scanner was working previously, but the retrieving of links was not working because the followsymlinks attribute was not passed through. Revision Changes Path 1.26 +15 -0 ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java Index: AbstractFileSet.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- AbstractFileSet.java 13 Aug 2003 15:14:31 -0000 1.25 +++ AbstractFileSet.java 14 Aug 2003 14:47:54 -0000 1.26 @@ -330,6 +330,21 @@ } /** + * find out if the fileset wants to follow symbolic links + * + * @return flag indicating whether or not symbolic links should be followed + * + * @since ant 1.6 + */ + public boolean isFollowSymlinks() { + if (isReference()) { + return getRef(getProject()).isFollowSymlinks(); + } else { + return followSymlinks; + } + } + + /** * sets the name used for this datatype instance. */ protected String getDataTypeName() { 1.47 +2 -2 ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java Index: FTP.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- FTP.java 14 Aug 2003 11:37:36 -0000 1.46 +++ FTP.java 14 Aug 2003 14:47:54 -0000 1.47 @@ -248,7 +248,6 @@ ftp.changeToParentDirectory(); return; } - for (int i = 0; i < newfiles.length; i++) { FTPFile file = newfiles[i]; if (!file.getName().equals(".") @@ -662,7 +661,7 @@ */ protected int transferFiles(FTPClient ftp, FileSet fs) throws IOException, BuildException { - FileScanner ds; + DirectoryScanner ds; if (action == SEND_FILES) { ds = fs.getDirectoryScanner(getProject()); @@ -674,6 +673,7 @@ } ds = new FTPDirectoryScanner(ftp); fs.setupDirectoryScanner(ds, getProject()); + ds.setFollowSymlinks(fs.isFollowSymlinks()); ds.scan(); } 1.6 +34 -0 ant/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java Index: FTPTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- FTPTest.java 6 Aug 2003 12:24:42 -0000 1.5 +++ FTPTest.java 14 Aug 2003 14:47:54 -0000 1.6 @@ -226,6 +226,40 @@ dsSource.scan(); compareFiles(dsSource, sortedDestinationFiles, sortedDestinationDirectories); } + public void testGetFollowSymlinksTrue() { + if (!supportsSymlinks) { + return; + } + if (!loginSuceeded) { + return; + } + if (!changeRemoteDir(remoteTmpDir)) { + return; + } + getProject().executeTarget("ftp-get-directory-symbolic-link"); + FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector"); + DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject()); + dsDestination.scan(); + compareFiles(dsDestination, new String[] {"alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + } + public void testGetFollowSymlinksFalse() { + if (!supportsSymlinks) { + return; + } + if (!loginSuceeded) { + return; + } + if (!changeRemoteDir(remoteTmpDir)) { + return; + } + getProject().executeTarget("ftp-get-directory-no-symbolic-link"); + FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector"); + DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject()); + dsDestination.scan(); + compareFiles(dsDestination, new String[] {}, + new String[] {}); + } public void testAllowSymlinks() { if (!supportsSymlinks) { return; 1.4 +26 -0 ant/src/etc/testcases/taskdefs/optional/net/ftp.xml Index: ftp.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/net/ftp.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ftp.xml 6 Aug 2003 12:24:42 -0000 1.3 +++ ftp.xml 14 Aug 2003 14:47:54 -0000 1.4 @@ -18,6 +18,12 @@ <fileset dir="${tmp.get.dir}" id="fileset-destination-without-selector"> <include name="alpha/**"/> </fileset> + <fileset dir="${tmp.get.dir}" id="fileset-destination-followsymlinks" followsymlinks="true"> + <include name="alpha/**"/> + </fileset> + <fileset dir="${tmp.get.dir}" id="fileset-destination-nofollowsymlinks" followsymlinks="false"> + <include name="alpha/**"/> + </fileset> <target name="setup"> <mkdir dir="${tmp.get.dir}"/> <mkdir dir="${tmp.dir}/alpha/beta/gamma"/> @@ -46,6 +52,26 @@ <delete dir="${tmp.dir}/alpha/beta"/> <symlink link="${tmp.dir}/alpha/beta" resource="${tmp.dir}/epsilon"/> <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/> + </target> + <target name="ftp-get-directory-symbolic-link" depends="symlink-setup"> + <ftp action="get" + server="${ftp.host}" + userid="${ftp.user}" + password="${ftp.password}" + remotedir="${tmp.dir}" + > + <fileset refid="fileset-destination-followsymlinks"/> + </ftp> + </target> + <target name="ftp-get-directory-no-symbolic-link" depends="symlink-setup"> + <ftp action="get" + server="${ftp.host}" + userid="${ftp.user}" + password="${ftp.password}" + remotedir="${tmp.dir}" + > + <fileset refid="fileset-destination-nofollowsymlinks"/> + </ftp> </target> <target name="symlink-file-setup" depends="setup"> <delete file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]