ftputil version: 2.2.2
python: 2.5.1
ftpserver: any, (i used proftpd on localhost)
OS: Linux julian-laptop 2.6.20-16-generic
#2
SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux
makedirs(self, path) creates the whole path, but doesn't start in root
dir but in the current working dir (cwd).
no traceback is possible as no errors occur
import ftputil
h = ftputil.FTPHost(server, name, password)
# cwd=/
# assuming root dir of host has an empty directory foo
h.chdir('foo')
# cwd=/foo
h.makedirs('bar/helloworld')
# this should have created /foo/bar/helloworld
# instead it created /foo/foo/bar/helloworld
h.makedirs('/meaning/of/life')
# this should have created /meaning/of/life
# instead it created /foo/meaning/of/life
in ftputil.py, function makedirs(self, path, mode=None)
because of
path = self.path.abspath(path)
directories = path.split(self.sep)
path must start with '/' char (root dir), leaving directories as a list
with first element an empty string.
then, later next_directory will be constructed as
next_directory = self.path.join(*directories[:index+1])
next_directory will never be an absolute path but a relative one.
change line 611 in fptutil/ftputil.py
next_directory = self.sep + self.path.join(*directories[:index+1])
btw, thanks for the great module!
julian
Hi Julian,
It seems you're right. :-) I added some test code and your fix to the trunk (in changeset 713). Thanks for not only reporting the bug but investigating it and providing a fix, too.