Skip to content

Commit

Permalink
Fix FTP multiple nested paths (#886)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Schneier <josh.schneier@gmail.com>
  • Loading branch information
Douglas Paz and jschneier authored May 31, 2020
1 parent b116e3a commit 993833b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion storages/backends/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def disconnect(self):

def _mkremdirs(self, path):
pwd = self._connection.pwd()
path_splitted = os.path.split(path)
path_splitted = path.split(os.path.sep)
for path_part in path_splitted:
try:
self._connection.cwd(path_part)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def test_mkremdirs(self, mock_ftp):
self.storage._start_connection()
self.storage._mkremdirs('foo/bar')

@patch('ftplib.FTP', **{'return_value.pwd.return_value': 'foo'})
def test_mkremdirs_n_subdirectories(self, mock_ftp):
self.storage._start_connection()
self.storage._mkremdirs('foo/bar/null')

@patch('ftplib.FTP', **{
'return_value.pwd.return_value': 'foo',
'return_value.storbinary.return_value': None
Expand Down

0 comments on commit 993833b

Please sign in to comment.