From c45f9dbeb4c98a0f6df32e9c970de22a7dbd116f Mon Sep 17 00:00:00 2001 From: btimby Date: Mon, 23 Apr 2012 19:58:49 +0000 Subject: Ensure files are not treated as directories (even when they are :-) git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@785 67cdc799-7952-0410-af00-57a81ceafa0f --- fs/expose/ftp.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/expose/ftp.py b/fs/expose/ftp.py index 51880e7..714e8b6 100644 --- a/fs/expose/ftp.py +++ b/fs/expose/ftp.py @@ -147,10 +147,15 @@ class FTPFS(ftpserver.AbstractedFS): elif 'st_mtime' in kwargs: # As a last resort, just copy the modified time. kwargs['st_ctime'] = kwargs['st_mtime'] - if self.fs.isdir(path): - kwargs['st_mode'] = 0777 | stat.S_IFDIR - else: - kwargs['st_mode'] = 0777 | stat.S_IFREG + mode = 0777 + # Merge in the type (dir or file). File is tested first, some file systems + # such as ArchiveMountFS treat archive files as directories too. By checking + # file first, any such files will be only files (not directories). + if self.fs.isfile(path): + mode |= stat.S_IFREG + elif self.fs.isdir(path): + mode |= stat.S_IFDIR + kwargs['st_mode'] = mode return FakeStat(**kwargs) # No link support... -- cgit v1.2.1