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)