Skip to content

Commit

Permalink
SFTPStorage: remove _pathmod indirection
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Aug 26, 2018
1 parent 938907c commit 0c03a8f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions storages/backends/sftpstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ def __init__(self, host=None, params=None, interactive=None, file_mode=None,
if root_path is None else root_path
self._base_url = setting('MEDIA_URL') if base_url is None else base_url

# for now it's all posix paths. Maybe someday we'll support figuring
# out if the remote host is windows.
self._pathmod = posixpath
self._sftp = None

def _connect(self):
Expand Down Expand Up @@ -95,12 +92,8 @@ def sftp(self):
self._connect()
return self._sftp

def _join(self, *args):
# Use the path module for the remote host type to join a path together
return self._pathmod.join(*args)

def _remote_path(self, name):
return self._join(self._root_path, name)
return posixpath.join(self._root_path, name)

def _open(self, name, mode='rb'):
return SFTPStorageFile(name, self, mode)
Expand All @@ -122,7 +115,7 @@ def _chown(self, path, uid=None, gid=None):
def _mkdir(self, path):
"""Create directory, recursing up to create parent dirs if
necessary."""
parent = self._pathmod.dirname(path)
parent = posixpath.dirname(path)
if not self.exists(parent):
self._mkdir(parent)
self.sftp.mkdir(path)
Expand All @@ -137,7 +130,7 @@ def _save(self, name, content):
"""Save file via SFTP."""
content.open()
path = self._remote_path(name)
dirname = self._pathmod.dirname(path)
dirname = posixpath.dirname(path)
if not self.exists(dirname):
self._mkdir(dirname)

Expand Down

0 comments on commit 0c03a8f

Please # to comment.