RFC3659: discard current and parent directories

These are never returned by a LIST command so ignore them for
consistency.
This commit is contained in:
Ludovic Fauvet 2016-02-02 16:36:25 +01:00
parent 95f4fe9d35
commit 79a78d10ee

7
ftp.go
View File

@ -325,7 +325,10 @@ func parseRFC3659ListLine(line string) (*Entry, error) {
}
case "type":
switch value {
case "dir", "cdir", "pdir":
case "cdir", "pdir":
// Discard current and parent dir
return nil, nil
case "dir":
e.Type = EntryTypeFolder
case "file":
e.Type = EntryTypeFile
@ -541,7 +544,7 @@ func (c *ServerConn) List(path string) (entries []*Entry, err error) {
for scanner.Scan() {
line := scanner.Text()
entry, err := parseListLine(line)
if err == nil {
if err == nil && entry != nil {
entries = append(entries, entry)
}
}