Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
perf: compute post-runtime hashes in parallel
NTFSvolume483cfa4a8dbd
diff --git a/cyberdrop_dl/hasher.py b/cyberdrop_dl/hasher.pyindex af03c54c8..fd8c341a9 100644--- a/cyberdrop_dl/hasher.py+++ b/cyberdrop_dl/hasher.py@@ -217,23 +217,23 @@ class Hasher:self._hashes_map[hash_value][size].add(absolute_path)self._hashed_items.add(media_item.id)- async def run(self, downloads: Iterable[FinishedDownload]) -> FileHashes:- with self.tui():- return await self._get_file_hashes_dict(downloads)-- async def _get_file_hashes_dict(self, downloads: Iterable[MediaItem | FinishedDownload]) -> FileHashes:- pending = (item for item in downloads if item.id not in self._hashed_items)-- async def exists(item: MediaItem | FinishedDownload) -> bool:- return await aio.is_file(item.path)+ async def run(self, downloads: Iterable[MediaItem | FinishedDownload]) -> FileHashes:+ async def compute_hash(item: MediaItem | FinishedDownload) -> None:+ if not await aio.is_file(item.path):+ return- for media_item in await aio.afilter(exists, pending):try:- await self.hash_item(media_item)+ await self.hash_item(item)except Exception:- logger.exception("Unable to hash '%s'", media_item.path)+ logger.exception("Unable to compute hashes for '%s' [%s]", item.path, item.id)++ with self.tui():+ async with aio.non_cancelling_taskgroup() as tg:+ for item in downloads:+ if item.id not in self._hashed_items:+ tg.create_task(compute_hash(item))- return self._hashes_map+ return self._hashes_mapasync def compute_in_place_hash(hasher: Hasher, media_item: MediaItem) -> None: