RFC3659: discard current and parent directories
These are never returned by a LIST command so ignore them for consistency.
This commit is contained in:
parent
95f4fe9d35
commit
79a78d10ee
7
ftp.go
7
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user