Skip to content

Conversation

sjsimps
Copy link

@sjsimps sjsimps commented Feb 11, 2019

I've encountered some cases where the default parseLIST function fails to parse the outcome of a LIST command, despite getting useful data. This was encountered while communicating with an older FTP server.

Rather than attempting to cover all the types of output an FTP server could give in response to a LIST command, I've added the ability to specify a custom ListParser to handle these cases.

Here's a sample format i've seen that could not be handled, with fake fields:
OWNER 777 11/12/13 01:02:03 TYPE /some/directory/file.txt


// Provide a custom parser for the outcome of the LIST command
// If this is not set, a default LIST parser is used that will handle most outcomes
ListParser interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be a function instead of an interface?

}
parser = func(entry string, skipSelfParent bool) (os.FileInfo, error) {
if c.config.ListParser != nil {
return c.config.ListParser.ParseLIST(entry)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the skipSelfParent flag? (I think its purpose is to exclude "." and ".." when listing.) Perhaps instead of passing that flag into the parser, we could exclude "." and ".." here using the return value?


// Provide a custom parser for the outcome of the LIST command
// If this is not set, a default LIST parser is used that will handle most outcomes
ListParser interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for the new functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants