Fix asynchronous methods being not awaited

This commit is contained in:
Joscha 2021-05-13 19:39:49 +02:00
parent 910462bb72
commit 68781a88ab
2 changed files with 10 additions and 10 deletions

View File

@ -242,7 +242,7 @@ class Crawler(ABC):
path, mtime, redownload, on_conflict) path, mtime, redownload, on_conflict)
async def cleanup(self) -> None: async def cleanup(self) -> None:
self._output_dir.cleanup() await self._output_dir.cleanup()
async def run(self) -> None: async def run(self) -> None:
""" """

View File

@ -340,30 +340,30 @@ class OutputDirectory:
f"[bold bright_green]Added[/] {escape(str(info.path))}") f"[bold bright_green]Added[/] {escape(str(info.path))}")
self._report.add_file(info.path) self._report.add_file(info.path)
def cleanup(self) -> None: async def cleanup(self) -> None:
self._cleanup_dir(self._root, PurePath()) 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(): if path.is_dir():
self._cleanup_dir(path, pure) await self._cleanup_dir(path, pure)
elif path.is_file(): 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(): for child in path.iterdir():
pure_child = pure / child.name pure_child = pure / child.name
self._cleanup(child, pure_child) await self._cleanup(child, pure_child)
try: try:
path.rmdir() path.rmdir()
except OSError: except OSError:
pass 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): if self._report.marked(pure):
return return
if self._conflict_delete_lf(self._on_conflict, pure): if await self._conflict_delete_lf(self._on_conflict, pure):
try: try:
path.unlink() path.unlink()
self._conductor.print( self._conductor.print(