Skip to content

Bulk asynchronous downloader for multiple file hosts

fix create file hash

datawhores93825a014ca5
diff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.py
index a5f4039de..7f932baee 100644
--- a/cyberdrop_dl/clients/hash_client.py
+++ b/cyberdrop_dl/clients/hash_client.py
@@ -1,13 +1,25 @@
import pathlib
+import asyncio
from contextlib import asynccontextmanager
from collections import defaultdict
-import asyncio
from cyberdrop_dl.utils.utilities import log
from send2trash import send2trash
from cyberdrop_dl.utils.dataclasses.url_objects import MediaItem
+@asynccontextmanager
+async def hash_scan_directory_context(manager):
+ await manager.async_db_hash_startup()
+ yield
+ await manager.close()
+
+def hash_directory_scanner(manager,path):
+ asyncio.run(_hash_directory_scanner_helper(manager,path))
+
+async def _hash_directory_scanner_helper(manager,path):
+ async with hash_scan_directory_context(manager):
+ await manager.hash_manager.hash_client.hash_directory(path)
class HashClient:
@@ -22,11 +34,9 @@ class HashClient:
await self.manager.async_db_hash_startup()
yield
await self.manager.close()
-
- def hash_directory(self,path):
- asyncio.run(self._hash_directory_helper(path))
- async def _hash_directory_helper(self,path):
+
+ async def hash_directory(self,path):
async with self._manager_context():
async with self.manager.live_manager.get_hash_live(stop=True):
#force start live manager for db connection
diff --git a/cyberdrop_dl/ui/ui.py b/cyberdrop_dl/ui/ui.py
index aad91add1..87861596b 100644
--- a/cyberdrop_dl/ui/ui.py
+++ b/cyberdrop_dl/ui/ui.py
@@ -16,6 +16,7 @@ from cyberdrop_dl.ui.prompts.settings_global_prompts import edit_global_settings
from cyberdrop_dl.ui.prompts.url_file_prompts import edit_urls_prompt
from cyberdrop_dl.ui.prompts.settings_user_prompts import create_new_config_prompt, edit_config_values_prompt
from cyberdrop_dl.ui.prompts.settings_hash_prompts import path_prompt
+from cyberdrop_dl.clients.hash_client import hash_directory_scanner
console = Console()
@@ -50,7 +51,7 @@ def program_ui(manager: Manager):
# Scanning folder to create hashes
elif action == 4:
path=path_prompt(manager)
- manager.hash_manager.hash_client.hash_directory(path)
+ hash_directory_scanner(manager,path)
# Sort All Configs
elif action == 5: