From 9440a16d62b8cdb9c1d1d804dccb389da3f6429c Mon Sep 17 00:00:00 2001 From: Nikolai Korolev Date: Wed, 12 Jul 2023 16:37:01 +0100 Subject: [PATCH] do not output `.` and `..` in `client.list(*, recursive=True)` as these create symlink loop on all ftp servers with UNIX systems (#166) --- aioftp/client.py | 3 +++ history.rst | 3 +++ 2 files changed, 6 insertions(+) diff --git a/aioftp/client.py b/aioftp/client.py index 2e40e7e..0c3ec85 100644 --- a/aioftp/client.py +++ b/aioftp/client.py @@ -796,6 +796,9 @@ async def __anext__(cls): raise StopAsyncIteration name, info = cls.parse_line(line) + # skipping . and .. as these are symlinks in Unix + if str(name) in (".", ".."): + continue stat = cls.path / name, info if info["type"] == "dir" and recursive: cls.directories.append(stat) diff --git a/history.rst b/history.rst index d939d5c..aa0cb8d 100644 --- a/history.rst +++ b/history.rst @@ -1,5 +1,8 @@ x.x.x (xx-xx-xxxx) + +0.22.0 (xx-xx-xxxx) ------------------ +- client.list: fix infinite symlink loop for `.` and `..` on FTP servers with UNIX-like filesystem for `client.list(path, recursive=True)` 0.21.4 (13-10-2022) -------------------