git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275463 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -77,4 +77,27 @@ | |||||
| <symlink link="${tmp.dir}/alpha/beta/gamma/gamma.xml" | <symlink link="${tmp.dir}/alpha/beta/gamma/gamma.xml" | ||||
| resource="${tmp.dir}/alpha/beta/beta.xml"/> | resource="${tmp.dir}/alpha/beta/beta.xml"/> | ||||
| </target> | </target> | ||||
| <target name="ftp-delete"> | |||||
| <!-- this target can produce an error if the rmdir does not work --> | |||||
| <!-- there can be problems with the rmdir action if the directories are not removed in a proper order --> | |||||
| <!-- which means beginning by the leaves of the tree, going back to the trunk --> | |||||
| <ftp action="del" | |||||
| server="${ftp.host}" | |||||
| userid="${ftp.user}" | |||||
| password="${ftp.password}" | |||||
| remotedir="${tmp.dir}"> | |||||
| <fileset dir="${tmp.get.dir}"> | |||||
| <include name="**"/> | |||||
| </fileset> | |||||
| </ftp> | |||||
| <ftp action="rmdir" | |||||
| server="${ftp.host}" | |||||
| userid="${ftp.user}" | |||||
| password="${ftp.password}" | |||||
| remotedir="${tmp.dir}"> | |||||
| <fileset dir="${tmp.get.dir}"> | |||||
| <include name="**"/> | |||||
| </fileset> | |||||
| </ftp> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -1357,30 +1357,34 @@ public class FTP | |||||
| } | } | ||||
| bw = new BufferedWriter(new FileWriter(listing)); | bw = new BufferedWriter(new FileWriter(listing)); | ||||
| } | } | ||||
| for (int i = 0; i < dsfiles.length; i++) { | |||||
| switch (action) { | |||||
| case SEND_FILES: | |||||
| sendFile(ftp, dir, dsfiles[i]); | |||||
| break; | |||||
| case GET_FILES: | |||||
| getFile(ftp, dir, dsfiles[i]); | |||||
| break; | |||||
| case DEL_FILES: | |||||
| delFile(ftp, dsfiles[i]); | |||||
| break; | |||||
| case LIST_FILES: | |||||
| listFile(ftp, bw, dsfiles[i]); | |||||
| break; | |||||
| case CHMOD: | |||||
| doSiteCommand(ftp, "chmod " + chmod + " " + resolveFile(dsfiles[i])); | |||||
| transferred++; | |||||
| break; | |||||
| case RM_DIR: | |||||
| rmDir(ftp, dsfiles[i]); | |||||
| break; | |||||
| default: | |||||
| throw new BuildException("unknown ftp action " + action); | |||||
| if (action == RM_DIR) { | |||||
| // to remove directories, start by the end of the list | |||||
| // the trunk does not let itself be removed before the leaves | |||||
| for (int i = dsfiles.length - 1; i >= 0; i--) { | |||||
| rmDir(ftp, dsfiles[i]); | |||||
| } | |||||
| } else { | |||||
| for (int i = 0; i < dsfiles.length; i++) { | |||||
| switch (action) { | |||||
| case SEND_FILES: | |||||
| sendFile(ftp, dir, dsfiles[i]); | |||||
| break; | |||||
| case GET_FILES: | |||||
| getFile(ftp, dir, dsfiles[i]); | |||||
| break; | |||||
| case DEL_FILES: | |||||
| delFile(ftp, dsfiles[i]); | |||||
| break; | |||||
| case LIST_FILES: | |||||
| listFile(ftp, bw, dsfiles[i]); | |||||
| break; | |||||
| case CHMOD: | |||||
| doSiteCommand(ftp, "chmod " + chmod + " " + resolveFile(dsfiles[i])); | |||||
| transferred++; | |||||
| break; | |||||
| default: | |||||
| throw new BuildException("unknown ftp action " + action); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } finally { | } finally { | ||||
| @@ -570,7 +570,12 @@ public class FTPTest extends BuildFileTest{ | |||||
| new String[] {"alpha/beta", "alpha/beta/gamma", "delta"}); | new String[] {"alpha/beta", "alpha/beta/gamma", "delta"}); | ||||
| } | } | ||||
| /** | |||||
| * this test is inspired by a user reporting that deletions of directories with the ftp task do not work | |||||
| */ | |||||
| public void testFTPDelete() { | |||||
| getProject().executeTarget("ftp-delete"); | |||||
| } | |||||
| private void compareFiles(DirectoryScanner ds, String[] expectedFiles, | private void compareFiles(DirectoryScanner ds, String[] expectedFiles, | ||||
| String[] expectedDirectories) { | String[] expectedDirectories) { | ||||
| String includedFiles[] = ds.getIncludedFiles(); | String includedFiles[] = ds.getIncludedFiles(); | ||||