mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
ssh: fix bug in remove()
This commit is contained in:
@@ -156,14 +156,12 @@ class SSHConnection:
|
||||
def _remove_dir(self, path):
|
||||
for root, dirs, files in self.walk(path, topdown=False):
|
||||
for fname in files:
|
||||
path = posixpath.join(root, fname)
|
||||
with suppress(FileNotFoundError):
|
||||
self._remove_file(path)
|
||||
self._remove_file(posixpath.join(root, fname))
|
||||
|
||||
for dname in dirs:
|
||||
path = posixpath.join(root, dname)
|
||||
with suppress(FileNotFoundError):
|
||||
self.sftp.rmdir(dname)
|
||||
self.sftp.rmdir(posixpath.join(root, dname))
|
||||
|
||||
with suppress(FileNotFoundError):
|
||||
self.sftp.rmdir(path)
|
||||
|
||||
@@ -35,6 +35,16 @@ def test_makedirs(tmp_path, ssh):
|
||||
assert os.path.isdir(path)
|
||||
|
||||
|
||||
def test_remove_dir(tmp_path, ssh):
|
||||
dpath = tmp_path / "dir"
|
||||
dpath.mkdir()
|
||||
(dpath / "file").write_text("file")
|
||||
(dpath / "subdir").mkdir()
|
||||
(dpath / "subdir" / "subfile").write_text("subfile")
|
||||
ssh.remove(dpath.absolute().as_posix())
|
||||
assert not dpath.exists()
|
||||
|
||||
|
||||
def test_walk(tmp_path, ssh):
|
||||
root_path = tmp_path
|
||||
dir_path = root_path / "dir"
|
||||
|
||||
Reference in New Issue
Block a user