From 79a78d10eeaa6461d2cff8c98b477b08ab3c7967 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Tue, 2 Feb 2016 16:36:25 +0100 Subject: [PATCH] RFC3659: discard current and parent directories These are never returned by a LIST command so ignore them for consistency. --- ftp.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ftp.go b/ftp.go index 66dcf54..175b967 100644 --- a/ftp.go +++ b/ftp.go @@ -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) } }