Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: log computed hashes

NTFSvolume94d976691e7b
diff --git a/cyberdrop_dl/hasher.py b/cyberdrop_dl/hasher.py
index bf470651e..b80473fc9 100644
--- a/cyberdrop_dl/hasher.py
+++ b/cyberdrop_dl/hasher.py
@@ -128,17 +128,28 @@ class Hasher:
except IsADirectoryError:
return None
+ hashes: dict[str, asyncio.Task[str | None]] = {}
+
def compute_hash(algo: Literal["xxh128", "md5", "sha256"]) -> asyncio.Task[str | None]:
- return tg.create_task(self._update_db_and_retrive_hash(file, original_filename, referer, algo))
+ hashes[algo] = task = tg.create_task(
+ self._update_db_and_retrive_hash(file, original_filename, referer, algo)
+ )
+ return task
async with self._sem:
with self.tui.new_file(file):
async with asyncio.TaskGroup() as tg:
logger.info("Computing hashes of '%s'", file)
- xxxhash = compute_hash("xxh128")
+ xxxhash = [] = compute_hash("xxh128")
for algo in self.extra_hashes:
_ = compute_hash(algo)
+ logger.debug(
+ "hashes of '%s'\n%s",
+ file,
+ {algo: result for algo, task in hashes.items() if (result := task.result()) is not None},
+ )
+
return xxxhash.result()
async def _update_db_and_retrive_hash(