From 68781a88ab607060e909d8985b436c4de0ce4779 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 13 May 2021 19:39:49 +0200 Subject: [PATCH] Fix asynchronous methods being not awaited --- PFERD/crawler.py | 2 +- PFERD/output_dir.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PFERD/crawler.py b/PFERD/crawler.py index 5148d9d..da35801 100644 --- a/PFERD/crawler.py +++ b/PFERD/crawler.py @@ -242,7 +242,7 @@ class Crawler(ABC): path, mtime, redownload, on_conflict) async def cleanup(self) -> None: - self._output_dir.cleanup() + await self._output_dir.cleanup() async def run(self) -> None: """ diff --git a/PFERD/output_dir.py b/PFERD/output_dir.py index 18e0b6a..635ee43 100644 --- a/PFERD/output_dir.py +++ b/PFERD/output_dir.py @@ -340,30 +340,30 @@ class OutputDirectory: f"[bold bright_green]Added[/] {escape(str(info.path))}") self._report.add_file(info.path) - def cleanup(self) -> None: - self._cleanup_dir(self._root, PurePath()) + async def cleanup(self) -> None: + await self._cleanup_dir(self._root, PurePath()) - def _cleanup(self, path: Path, pure: PurePath) -> None: + async def _cleanup(self, path: Path, pure: PurePath) -> None: if path.is_dir(): - self._cleanup_dir(path, pure) + await self._cleanup_dir(path, pure) elif path.is_file(): - self._cleanup_file(path, pure) + await self._cleanup_file(path, pure) - def _cleanup_dir(self, path: Path, pure: PurePath) -> None: + async def _cleanup_dir(self, path: Path, pure: PurePath) -> None: for child in path.iterdir(): pure_child = pure / child.name - self._cleanup(child, pure_child) + await self._cleanup(child, pure_child) try: path.rmdir() except OSError: pass - def _cleanup_file(self, path: Path, pure: PurePath) -> None: + async def _cleanup_file(self, path: Path, pure: PurePath) -> None: if self._report.marked(pure): return - if self._conflict_delete_lf(self._on_conflict, pure): + if await self._conflict_delete_lf(self._on_conflict, pure): try: path.unlink() self._conductor.print(