summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2012-04-23 19:58:49 +0000
committerbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2012-04-23 19:58:49 +0000
commitc45f9dbeb4c98a0f6df32e9c970de22a7dbd116f (patch)
tree9d9e0ed04a5c1dae49d039701dd622e31aff45af
parentcdc8c72116aa953f3c78119610231b7c61928ab6 (diff)
downloadpyfilesystem-c45f9dbeb4c98a0f6df32e9c970de22a7dbd116f.tar.gz
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
-rw-r--r--fs/expose/ftp.py13
1 files 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...