Skip to content

Bulk asynchronous downloader for multiple file hosts

Add check for if sort dir is in download dir.

Jules-WinnfieldX02786c2f1948
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index e3452ef8a..1f2ebf7ee 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "5.0.104"
+__version__ = "5.0.105"
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index 40e5f6096..e90326cde 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -135,7 +135,7 @@ def main():
with contextlib.suppress(RuntimeError, asyncio.CancelledError):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
- asyncio.run(director(manager))
+ aiorun.run(director(manager), stop_on_unhandled_errors=True, loop=loop)
sys.exit(0)
diff --git a/cyberdrop_dl/utils/sorting.py b/cyberdrop_dl/utils/sorting.py
index a7dc5df5e..a3e74c23f 100644
--- a/cyberdrop_dl/utils/sorting.py
+++ b/cyberdrop_dl/utils/sorting.py
@@ -55,9 +55,20 @@ class Sorter:
break
file.rename(dest)
+ async def check_dir_parents(self) -> bool:
+ """Checks if the sort dir is in the download dir"""
+ if self.download_dir in self.sorted_downloads.parents:
+ await log_with_color("Sort Directory cannot be in the Download Directory", "red")
+ return True
+ return False
+
async def sort(self) -> None:
"""Sorts the files in the download directory into their respective folders"""
await log_with_color("\nSorting Downloads: Please Wait", "cyan")
+
+ if await self.check_dir_parents():
+ return
+
for folder in self.download_dir.iterdir():
if not folder.is_dir():
continue
diff --git a/pyproject.toml b/pyproject.toml
index f9b2f9b3d..0c7f633ce 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
-version = "5.0.104"
+version = "5.0.105"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"