Skip to content

Bulk asynchronous downloader for multiple file hosts

Update hash_manager.py

datawhores3d69c617476b
diff --git a/cyberdrop_dl/managers/hash_manager.py b/cyberdrop_dl/managers/hash_manager.py
index 8b1378917..6cfea36b2 100644
--- a/cyberdrop_dl/managers/hash_manager.py
+++ b/cyberdrop_dl/managers/hash_manager.py
@@ -1 +1,23 @@
+class Hasher:
+ def __init__(self):
+ pass
+
+ def hash_file(filename):
+ file_hash = self.hasher()
+ with self.path.open("rb") as fp:
+ CHUNK_SIZE = 1024 * 1024 # 1 mb
+ filedata = fp.read(CHUNK_SIZE)
+ while filedata:
+ file_hash.update(filedata)
+ filedata = fp.read(CHUNK_SIZE)
+ return file_hash.digest()
+ @property
+ def hasher():
+ hasher: Callable
+ try:
+ import xxhash
+ return xxhash.xxh128
+ except ImportError:
+ import hashlib
+ return hashlib.md5