From c8a8662875d0dbedb3474b1d7496015b4a79f1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E7=A7=98=E7=9A=84man?= <2755488504@qq.com> Date: Thu, 19 Nov 2026 00:44:44 +0800 Subject: [PATCH 1/2] fix: synchronous `rmdir()` fails silently OSS-Contributor-Artifact: 679ddc0a35296cf762b24d17c4b87bdaba100df8da492fcf82efcb739ccd2836 --- sshfs/spec.py | 2 ++ tests/test_oss_regression_38.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/test_oss_regression_38.py diff --git a/sshfs/spec.py b/sshfs/spec.py index 2338040..b3da1fe 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -351,6 +351,8 @@ async def _rmdir( else: await channel.rmdir(path) + rmdir = sync_wrapper(_rmdir) + async def _rm(self, path, recursive=False, **kwargs): path = self._strip_protocol(path) if isinstance(path, (str, bytes)): diff --git a/tests/test_oss_regression_38.py b/tests/test_oss_regression_38.py new file mode 100644 index 0000000..6f6a18f --- /dev/null +++ b/tests/test_oss_regression_38.py @@ -0,0 +1,19 @@ +import pytest +from test_sshfs import fs, plain_remote_dir, remote_dir, ssh_server + + +def test_rmdir_removes_directory(fs, remote_dir): + path = remote_dir + "/empty" + fs.mkdir(path) + assert fs.isdir(path) + + fs.rmdir(path) + assert not fs.exists(path) + + with pytest.raises(FileNotFoundError): + fs.rmdir(path) + + fs.makedirs(path + "/child") + fs.touch(path + "/child/file") + fs.rmdir(path, recursive=True) + assert not fs.exists(path) From 2608949924b93b6d1f29865888d5cfb724b21c7e Mon Sep 17 00:00:00 2001 From: Ivan Shcheklein Date: Sun, 29 Nov 2026 09:39:52 -0800 Subject: [PATCH 2/2] test: move the rmdir test next to test_rm The other filesystem tests live in test_sshfs.py, so the rmdir test moves there from its own module, which had to import the fixtures. Co-Authored-By: Claude Opus 5.5 --- tests/test_oss_regression_38.py | 19 ------------------- tests/test_sshfs.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 tests/test_oss_regression_38.py diff --git a/tests/test_oss_regression_38.py b/tests/test_oss_regression_38.py deleted file mode 100644 index 6f6a18f..0000000 --- a/tests/test_oss_regression_38.py +++ /dev/null @@ -1,19 +0,0 @@ -import pytest -from test_sshfs import fs, plain_remote_dir, remote_dir, ssh_server - - -def test_rmdir_removes_directory(fs, remote_dir): - path = remote_dir + "/empty" - fs.mkdir(path) - assert fs.isdir(path) - - fs.rmdir(path) - assert not fs.exists(path) - - with pytest.raises(FileNotFoundError): - fs.rmdir(path) - - fs.makedirs(path + "/child") - fs.touch(path + "/child/file") - fs.rmdir(path, recursive=True) - assert not fs.exists(path) diff --git a/tests/test_sshfs.py b/tests/test_sshfs.py index 3c7f0b5..ffeab91 100644 --- a/tests/test_sshfs.py +++ b/tests/test_sshfs.py @@ -329,6 +329,23 @@ def test_rm(fs, remote_dir): assert not fs.exists(remote_dir + "/dir") +def test_rmdir_removes_directory(fs, remote_dir): + path = remote_dir + "/empty" + fs.mkdir(path) + assert fs.isdir(path) + + fs.rmdir(path) + assert not fs.exists(path) + + with pytest.raises(FileNotFoundError): + fs.rmdir(path) + + fs.makedirs(path + "/child") + fs.touch(path + "/child/file") + fs.rmdir(path, recursive=True) + assert not fs.exists(path) + + @pytest.mark.parametrize("name", ["back\\slash", "new\nline"]) def test_checksum_escaped_name(fs, plain_remote_dir, name): # GNU md5sum escapes these names in its output