FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

GetListing sometimes lists content of CWD instead of specified directory?

Open ExplodingCabbage opened this issue 7 years ago • 10 comments

I have no idea how to reproduce, but this appears to be the issue being described at https://stackoverflow.com/q/41466095/1709587

ExplodingCabbage avatar Jan 06 '18 23:01 ExplodingCabbage

Good catch, but I'll really need both the working (FileZilla) and the FluentFTP logs to compare them and see what gives.

robinrodricks avatar Jan 08 '18 17:01 robinrodricks

Yeah, it's hard to guess at what's going on without any information about what server they were using or how it was responding to requests.

ExplodingCabbage avatar Jan 08 '18 17:01 ExplodingCabbage

I saw this today on a non-standard FTP server hosted by an old embedded device. What I can tell is that when you ask the server to LIST /FOLDERNAME it just lists the folder name. When I look at the FileZilla logs I can see that what FileZilla is doing is changing directory in to that folder and then issuing a blank LIST. This behavior is required on the set of devices I am using. Let me know if you need me to do additional testing.

CWD /FOLDERNAME
LIST

A9G-Data-Droid avatar Jun 04 '20 23:06 A9G-Data-Droid

Here is a redacted example of the problem:

Status:   Connecting to 
Response: 220 FTP server ready.
Command:  USER ***
Response: 331 User name okay, need password.
Command:  PASS ***
Response: 230 User logged in, proceed.
Status:   Text encoding: System.Text.ASCIIEncoding
Command:  SYST
Response: 502 SYST command not implemented, or not allowed.
Warning:  Cannot auto-detect listing parser for system 'Unknown', using Unix parser
Command:  TYPE A
Response: 200 TYPE Command okay.
Command:  PASV
Response: 227 Entering Passive Mode ().
Status:   Connecting to 
Command:  LIST /FOLDERNAME
Response: 150 File status okay; about to open data connection.
+---------------------------------------+
Listing:  drwxrwxrwx   1 owner    group               0 Jan 01  2000 FOLDERNAME
-----------------------------------------
Status:   Disposing FtpSocketStream...
Response: 226 Closing data connection.
Status:   Disposing FtpSocketStream...
Status:   Confirmed format Unix
Command:  QUIT
Response: 221 Goodbye.
Status:   Disposing FtpSocketStream...
Status:   Disposing FtpClient object...
Status:   Disposing FtpSocketStream...

A9G-Data-Droid avatar Jun 05 '20 15:06 A9G-Data-Droid

To get the behavior I want I am using:

client.SetWorkingDirectory(ftpPath);
var ftpList = Await client.GetListingAsync(null, FtpListOption.NoPath);

It would be nice to have a Custom Server detection that would behave this way. I would write one for my case but I don't see GetListingAsync as an Extendable handlers here https://github.com/robinrodricks/FluentFTP/wiki/Custom-Servers.

Is this difficult to do?

NOTE: Solution is identical to what is proposed as the solution to #101

A9G-Data-Droid avatar Jun 05 '20 20:06 A9G-Data-Droid

See Wiki path problems

FanDjango avatar Sep 19 '22 15:09 FanDjango

Wait, the solution was to document the workaround? Why not have a custom server definition we can use when we need this behavior? Then I could just turn on the feature for servers that require it.

A9G-Data-Droid avatar Sep 19 '22 18:09 A9G-Data-Droid

Ok, I see what you are saying. Let's put Extendable Server Detection on the bucket list. Is that a good next step?

But that would not be enough. You and others would also want Extendable ?????-APIs as well. I know there are already a few, but is that a good direction to move in?

The trend at the moment goes toward having this "workaround" behaviour become the norm for all servers anyway. But that is a big next step right now.

FanDjango avatar Sep 19 '22 18:09 FanDjango

@A9G-Data-Droid This is now pending being transferred to the list of planned enhancements. Then this issue will once again be closed.

What you are requesting is already in the overall plan, so this is slightly redundant.

Referring this to the Wiki is to help those who browse these open or closed issues and need an immediate workaround to achieve their goals without waiting for enhancements.

FanDjango avatar Sep 19 '22 19:09 FanDjango

@A9G-Data-Droid We are planning on having this behavior done automatically, so we are in line with how filezilla handles things. It was planned for v40 but skipped due to lack of time. I'm aware of this. See - https://github.com/robinrodricks/FluentFTP/wiki/Future-Plans#getlisting-path-handling

robinrodricks avatar Sep 20 '22 05:09 robinrodricks