Commit a93139a2 by btimby

Pyftpdlib 1.x uses unicode, the provided path will already be unicode and thus…

Pyftpdlib 1.x uses unicode, the provided path will already be unicode and thus does not require decoding.
Detect if the provided path is unicode or not before attempting decoding. Use six.unicode to preserve compatibility with py3.
parent 3ea4efe1
...@@ -28,6 +28,7 @@ from fs.osfs import OSFS ...@@ -28,6 +28,7 @@ from fs.osfs import OSFS
from fs.errors import convert_fs_errors from fs.errors import convert_fs_errors
from fs import iotools from fs import iotools
from six import unicode
# Get these once so we can reuse them: # Get these once so we can reuse them:
UID = os.getuid() UID = os.getuid()
...@@ -105,7 +106,12 @@ class FTPFS(ftpserver.AbstractedFS): ...@@ -105,7 +106,12 @@ class FTPFS(ftpserver.AbstractedFS):
def chdir(self, path): def chdir(self, path):
# We dont' use the decorator here, we actually decode a version of the # We dont' use the decorator here, we actually decode a version of the
# path for use with pyfs, but keep the original for use with pyftpdlib. # path for use with pyfs, but keep the original for use with pyftpdlib.
unipath = unicode(path, self.encoding) if not isinstance(path, unicode):
# pyftpdlib 0.7.x
unipath = unicode(path, self.encoding)
else:
# pyftpdlib 1.x
unipath = path
# TODO: can the following conditional checks be farmed out to the fs? # TODO: can the following conditional checks be farmed out to the fs?
# If we don't raise an error here for files, then the FTP server will # If we don't raise an error here for files, then the FTP server will
# happily allow the client to CWD into a file. We really only want to # happily allow the client to CWD into a file. We really only want to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment