From 68871d3150db2ede58712dff85b5c68e46c9070f Mon Sep 17 00:00:00 2001 From: Daniel Crawl Date: Sun, 28 Sep 2025 10:15:17 -0700 Subject: [PATCH] try copy() instead of using shell cp since some SFTP servers support copy-data extension --- sshfs/spec.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sshfs/spec.py b/sshfs/spec.py index 046a6ec..fd7eb93 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -203,6 +203,12 @@ async def _get_file( @wrap_exceptions async def _cp_file(self, lpath, rpath, **kwargs): + # some SFTP servers support the copy-data extension + with suppress(SFTPOpUnsupported): + async with self._pool.get() as channel: + await channel.copy(lpath, rpath) + return + cmd = f"cp {shlex.quote(lpath)} {shlex.quote(rpath)}" await self._execute(cmd)