Skip to content

FTPFS: Problem with Gene6 FTP Server: Parent directories are listed as well #249

@hoffleit

Description

@hoffleit

When working with FTPFS against a Gene6 FTP Server v3.8.0 (Build 34), I ran into the situation that the listings of listdir() and listdirinfo() included the parent directory and the parents parent directory:

>>> ftp = FTPFS(host = gene6ftp)
>>> ftp.listdir()
[u'dir1', u'dir2', u'/', u'dir3']
>>> ftp.listdir('dir1')
[u'dir11', u'/dir1', u'/']
>>> ftp.listdir('dir1/dir11)
[u'dir111', u'dir112, u'/dir1/dir11', u'/dir1', u'dir113', u'dir114', u'dir115']
>>> ftp.listdir('dir1/dir11/dir114)
[u'file1141', u'file1142', u'/dir1/dir11', u'file1143', u'/dir1/dir11/dir114', u'file1144']

The directory tree looked like this:

/dir1
/dir1/dir11/dir111
/dir1/dir11/dir112
/dir1/dir11/dir113
/dir1/dir11/dir114
/dir1/dir11/dir114/file1141
/dir1/dir11/dir114/file1142
/dir1/dir11/dir114/file1143
/dir1/dir11/dir114/file1144
/dir1/dir11/dir115
/dir2
/dir3

I came up with the following modification for ftpfs, which worked for me:

--- fs/ftpfs.py.ORIG    2016-03-24 16:56:42.618053706 +0100
+++fs/ftpfs.py  2016-03-24 16:57:22.551270915 +0100
@@ -553,8 +553,10 @@
                 elif factname == 'type':
                     if factvalue.lower() == 'file':
                         result.try_retr = True
-                    elif factvalue.lower() in ['dir', 'cdir', 'pdir']:
+                    elif factvalue.lower() == 'dir':
                         result.try_cwd = True
+                    elif factvalue.lower() in ['cdir', 'pdir']:
+                        return None
                     else:
                         # dunno if it's file or directory
                         result.try_retr = True

I.e. I dropped the lines with cdir and pdir, since they seemed to make no sense for this directory listing.

Here is an example for a listing from this Gene6 FTP server:

type=dir;modify=20160217175246; /dir1/dir11
type=cdir;modify=20160217175246; /dir1/dir11
type=pdir;modify=20160217175208; ..
type=pdir;modify=20160217175208; /dir1
type=dir;modify=20160217175236; dir111
type=dir;modify=20160324152742; dir112
type=dir;modify=20160324152803; dir113
type=dir;modify=20160217175219; dir114
type=dir;modify=20160217175216; dir115

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions