Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: do not delete empty `.py` files

NTFSvolume4f7f5d947cdf
diff --git a/cyberdrop_dl/utils/cleanup.py b/cyberdrop_dl/utils/cleanup.py
index 1893088b7..48e74a625 100644
--- a/cyberdrop_dl/utils/cleanup.py
+++ b/cyberdrop_dl/utils/cleanup.py
@@ -87,12 +87,22 @@ def rm_empty_dirs(path: Path) -> None:
_ = _rm_empty_dirs(path, exclude=exclude)
+def _should_ignore(entry: os.DirEntry[str]) -> bool:
+ if entry.name.startswith("."):
+ return True
+ stem, _, ext = entry.name.rpartition(".")
+ if not stem:
+ return False
+ suffix = f".{ext.casefold()}"
+ return suffix in {".py", ".anchor"}
+
+
def _rm_empty_dirs(dirname: Path | str, exclude: Container[str] = ()) -> bool:
is_empty = True
try:
for entry in os.scandir(dirname):
- if entry.name.startswith(".") or entry.path in exclude:
+ if _should_ignore(entry) or entry.path in exclude:
is_empty = False
continue