diff --git a/WHATSNEW b/WHATSNEW index 4a2760cee..24ece6acd 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -142,6 +142,10 @@ Fixed bugs: * will remove target file (if it exists) before writing to it - this avoids problems with links on filesystems that support them. +* now properly recurses remote directories. + +* closes remote connection when it's done. + Changes from Ant 1.2 to Ant 1.3 =========================================== 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 bce41f315..55b17ab16 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 @@ -71,6 +71,14 @@ import org.apache.tools.ant.types.*; *
  • list - create a file listing.
  • * * + * Note: + * Some FTP servers - notably the Solaris server - seem to hold data ports + * open after a "retr" operation, allowing them to timeout instead of + * shutting them down cleanly. This happens in active or passive mode, + * and the ports will remain open even after ending the FTP session. + * FTP "send" operations seem to close ports immediately. This behavior + * may cause problems on some systems when downloading large sets of files. + * * @author Roger Vaughn rvaughn@seaconinc.com * @author Glenn McAllister glennm@ca.ibm.com */ @@ -154,50 +162,55 @@ public class FTP FTPFile[] newfiles = ftp.listFiles(); if (newfiles == null) { - return; // no files in directory. + ftp.changeToParentDirectory(); + return; } for (int i = 0; i < newfiles.length; i++) { FTPFile file = newfiles[i]; - String name = vpath + file.getName(); - if (file.isDirectory()) { - if (isIncluded(name)) { - if (!isExcluded(name)) { - dirsIncluded.addElement(name); - if (fast) { - scandir(name, name + File.separator, fast); + if (!file.getName().equals(".") && !file.getName().equals("..")) { + if (file.isDirectory()) { + String name = file.getName(); + if (isIncluded(name)) { + if (!isExcluded(name)) { + dirsIncluded.addElement(name); + if (fast) { + scandir(name, vpath + name + File.separator, fast); + } + } else { + dirsExcluded.addElement(name); } } else { - dirsExcluded.addElement(name); + dirsNotIncluded.addElement(name); + if (fast && couldHoldIncluded(name)) { + scandir(name, vpath + name + File.separator, fast); + } } - } else { - dirsNotIncluded.addElement(name); - if (fast && couldHoldIncluded(name)) { - scandir(name, name + File.separator, fast); + if (!fast) { + scandir(name, vpath + name + File.separator, fast); } - } - if (!fast) { - scandir(name, name + File.separator, fast); - } - } else { - if (file.isFile()) { - if (isIncluded(name)) { - if (!isExcluded(name)) { - filesIncluded.addElement(name); + } else { + if (file.isFile()) { + String name = vpath + file.getName(); + if (isIncluded(name)) { + if (!isExcluded(name)) { + filesIncluded.addElement(name); + } else { + filesExcluded.addElement(name); + } } else { - filesExcluded.addElement(name); + filesNotIncluded.addElement(name); } - } else { - filesNotIncluded.addElement(name); } } } } + ftp.changeToParentDirectory(); } catch (IOException e) { throw new BuildException("Error while communicating with FTP server: ", e); } } - } + } /** * Sets the remote directory where files will be placed. This may @@ -795,20 +808,19 @@ public class FTP } finally { - /* - if (ftp != null && ftp.isConnected()) - { - try - { - // this hangs - I don't know why. - ftp.disconnect(); - } - catch(IOException ex) - { - // ignore it - } - } - */ + if (ftp != null && ftp.isConnected()) + { + try + { + log("disconnecting", Project.MSG_VERBOSE); + ftp.logout(); + ftp.disconnect(); + } + catch(IOException ex) + { + // ignore it + } + } } } }