diff --git a/sshfs/spec.py b/sshfs/spec.py index 16f692d..ddee316 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -385,6 +385,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_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