From 9a81906f97afbe9b799ae0561a7c324d31f08774 Mon Sep 17 00:00:00 2001 From: Denis Rohr Date: Thu, 30 Oct 2025 14:42:41 +0100 Subject: [PATCH 1/2] File not found error when using SFTPFileSystem implementation in duckDB #1938 --- fsspec/implementations/sftp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fsspec/implementations/sftp.py b/fsspec/implementations/sftp.py index 77f7b370c..d3926bd3c 100644 --- a/fsspec/implementations/sftp.py +++ b/fsspec/implementations/sftp.py @@ -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}") @@ -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 @@ -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: @@ -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) @@ -168,6 +173,7 @@ def _rm(self, path): self.ftp.remove(path) def mv(self, old, new): + new = self._strip_protocol(new) logger.debug("Renaming %s into %s", old, new) self.ftp.posix_rename(old, new) From 2e75d09673faabde9cd30eccf46a28e763f723f6 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Thu, 30 Oct 2025 09:47:34 -0400 Subject: [PATCH 2/2] Update fsspec/implementations/sftp.py --- fsspec/implementations/sftp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fsspec/implementations/sftp.py b/fsspec/implementations/sftp.py index d3926bd3c..6a6db5b56 100644 --- a/fsspec/implementations/sftp.py +++ b/fsspec/implementations/sftp.py @@ -174,6 +174,7 @@ def _rm(self, 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)