ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 4411] New: - FTP task scandir method bug
Date Thu, 25 Oct 2001 07:26:51 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4411>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4411

FTP task scandir method bug

           Summary: FTP task scandir method bug
           Product: Ant
           Version: 1.4.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: Optional Tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: emercier@openup.fr
                CC: emercier@openup.fr


Hi;

before all, thank you so much for the FTP task which makes my life easier.
I have an heavy use of this task, and I discovered some weird behavior when 
handling remote files within nested directory from the remoteDir.

I took a look a the code, and eventually discovered the bug in the
protected void scandir(String dir, String vpath, boolean fast)
method from class
org.apache.tools.ant.taskdefs.optional.net.FTP

The bug is due to a confusion between file name and relative path name. Here is 
the fix that I propose. I've tested it and it seems to be allright now.

Do not hesitate to ask for anything, but please fix the bug in the next release 
because I'm working with my own version of optional.jar and it's not very 
comfortable.

Bests regards,
Edouard Mercier



        protected void scandir(String dir, String vpath, boolean fast) {
            try {
                if (!ftp.changeWorkingDirectory(dir)) {
                    return;
                }

                FTPFile[] newfiles = ftp.listFiles();
                if (newfiles == null) {
                    ftp.changeToParentDirectory();
                    return;
                }

                for (int i = 0; i < newfiles.length; i++) {
                    FTPFile file = newfiles[i];
                    if (!file.getName().equals(".") && !file.getName().equals
("..")) {
                        if (file.isDirectory()) {
                            String name = vpath+file.getName();
							if (isIncluded(name)) {
								if (!isExcluded
(name)) {
								
	dirsIncluded.addElement(name);
									if 
(fast) {
									
	scandir(file.getName(), name+File.separator, fast);
									}
								} else {
								
	dirsExcluded.addElement(name);
									if 
(fast && couldHoldIncluded(name)) {
									
	scandir(file.getName(), name+File.separator, fast);
									}
								}
							} else {
							
	dirsNotIncluded.addElement(name);
								if (fast && 
couldHoldIncluded(name)) {
									scandir
(file.getName(), name+File.separator, fast);
								}
							}
							if (!fast) {
								scandir
(file.getName(), name+File.separator, fast);
							}
                        } else {
                            if (file.isFile()) {
                                String name = vpath + file.getName();
								if (isIncluded
(name)) {
									if (!
isExcluded(name)) {
									
	filesIncluded.addElement(name);
									} else {
									
	filesExcluded.addElement(name);
									}
								} else {
								
	filesNotIncluded.addElement(name);
								}
                            }
                        }
                    }
                }
                ftp.changeToParentDirectory();
            } catch (IOException e) {
                throw new BuildException("Error while communicating with FTP 
server: ", e);
            }
        }
    }

Mime
View raw message