| Summary: | FTP can not view subdirectories | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Sergey Vladimirov <vlsergey> |
| Component: | Team | Assignee: | Platform Team Inbox <platform-team-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | blocker | ||
| Priority: | P3 | Keywords: | helpwanted |
| Version: | 3.1 | ||
| Target Milestone: | 3.1 M7 | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | |||
| Attachments: | |||
|
Description
Sergey Vladimirov
Versions of Eclipse and FTP&WebDAV - 3.1M4 The FTP plugin is not being actively developed. Patches will be accepted. I have no censured words. Just only this fix:
package org.eclipse.ftp.internal;
public class FTPClient implements IClient {
<...>
public IDirectoryEntry[] listFiles(String directoryPath, boolean
includeParents, IProgressMonitor monitor) throws FtpException {
monitor = FtpPlugin.monitorFor(monitor);
monitor.beginTask(null, 115);
final String title = FtpPlugin.getResourceString
("FTPClient.listFiles", directoryPath == null ? "." : directoryPath); //$NON-
NLS-1$ //$NON-NLS-2$
monitor.subTask(title);
DataConnection manager = null;
try {
if (directoryPath != null) {
sendCommand("CWD", directoryPath); //$NON-NLS-1$
monitor.worked(5);
switch (readResponseSkip100()) {
case 250:
// requested file action ok
break;
default:
defaultResponseHandler();
}
monitor.worked(10);
} else {
monitor.worked(15);
}
// Initiate the data transfer
manager = initiateDataTransfer("LIST -a", null, false,
0, FtpPlugin.monitorFor(monitor)); //$NON-NLS-1$
// Get the input stream from the data connection
monitor.subTask(FtpPlugin.getResourceString
("FTPClient.transferNoSize", title)); //$NON-NLS-1$
<...>
another fix for another issue.
package org.eclipse.ftp.internal;
<...>
public class FTPClient implements IClient {
<...>
private InputStream internalGetContents(String filePath, boolean
binary, long resumeAt, IProgressMonitor monitor) throws FtpException {
Assert.isNotNull(filePath);
DataConnection manager = null;
// send the request to the server
int tries = 0;
FtpException lastExc = null;
while (tries < 3) {
try {
manager = initiateDataTransfer(
"RETR", filePath, binary,
resumeAt, FtpPlugin.monitorFor(monitor)); //$NON-NLS-1$
lastExc = null;
} catch (FtpException exc) {
lastExc = exc;
}
tries++;
if (lastExc == null) {
break;
}
}
if (lastExc != null) {
throw lastExc;
}
InputStream in = manager.getDataTransferInputStream();
// setup line terminator conversion
if (! binary && ! Constants.IS_CRLF_PLATFORM) in = new
CRLFtoLFInputStream(in);
return in;
}
<...>
The code in comment #3 breaks the client for me (i.e. I can no longer expand my FTP site in the site explorer. I'm not keen on the code in comment #4 either since all it seems to do is try a few more times. Can you provide FTP account to test and fix changes? Sorry, I do not have the ability to do that. However, the ftp server I ran against was the obe that ships with RedHat 9.0. Created attachment 18326 [details]
Patch for org/eclipse/ftp/internal/FTPClient.java v1.2
There is a (probably related) bug that makes the FTP plugin list all 1st level subdirs of the directory when listing it. ie opening "home" will make the plugin send all those commands: LIST -a home/ LIST -a home/backup LIST -a home/gboudreau etc. which takes quite some time to execute... Created attachment 18327 [details]
Patch for org/eclipse/target/internal/ftp/FtpSite.java v1.2 and org/eclipse/target/internal/ftp/FtpTargetResource.java v1.3
Problem was deeper than I thought...
The TreeView is calling hasChildren() to check if it will display a "+" next to
the item; thus the (mostly) unneeded LIST -a called succesively.
The attached patch 'fix' this by keeping a counter of how many directories
there are under the current directory and skipping the next calls to LIST that
many times after that. Each time a LIST is skipped, a dummy element is returned
so that the TreeView will display a "+" for the item.
For me, the FtpPlugin was unusable without this patch... Listing my /home/pub/
was taking about a minute (~ 40 subdirs)...
I have submited the fix from comment 8. The fix in comment 10 made some assumptions that I didn't feel were safe to release but I found an alternate work around for that issue. |