Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions fsspec/implementations/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def _get_kwargs_from_urls(urlpath):
return out

def mkdir(self, path, create_parents=True, mode=511):
path = self._strip_protocol(path)
logger.debug("Creating folder %s", path)
if self.exists(path):
raise FileExistsError(f"File exists: {path}")
Expand All @@ -89,10 +90,12 @@ def makedirs(self, path, exist_ok=False, mode=511):
self.ftp.mkdir(new_path, mode)

def rmdir(self, path):
path = self._strip_protocol(path)
logger.debug("Removing folder %s", path)
self.ftp.rmdir(path)

def info(self, path):
path = self._strip_protocol(path)
stat = self._decode_stat(self.ftp.stat(path))
stat["name"] = path
return stat
Expand Down Expand Up @@ -123,6 +126,7 @@ def _decode_stat(stat, parent_path=None):
return out

def ls(self, path, detail=False):
path = self._strip_protocol(path)
logger.debug("Listing folder %s", path)
stats = [self._decode_stat(stat, path) for stat in self.ftp.listdir_iter(path)]
if detail:
Expand All @@ -132,6 +136,7 @@ def ls(self, path, detail=False):
return sorted(paths)

def put(self, lpath, rpath, callback=None, **kwargs):
rpath = self._strip_protocol(rpath)
logger.debug("Put file %s into %s", lpath, rpath)
self.ftp.put(lpath, rpath)

Expand Down Expand Up @@ -168,6 +173,8 @@ def _rm(self, path):
self.ftp.remove(path)

def mv(self, old, new):
new = self._strip_protocol(new)
old = self._strip_protocol(old)
logger.debug("Renaming %s into %s", old, new)
self.ftp.posix_rename(old, new)

Expand Down
Loading