Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: Hash Table Query Times (#1417)

Jacob44a89801a9e9
diff --git a/cyberdrop_dl/database/tables/definitions.py b/cyberdrop_dl/database/tables/definitions.py
index 55507e507..a40eedc33 100644
--- a/cyberdrop_dl/database/tables/definitions.py
+++ b/cyberdrop_dl/database/tables/definitions.py
@@ -70,3 +70,7 @@ CREATE TABLE IF NOT EXISTS temp_hash (
FOREIGN KEY (folder, download_filename) REFERENCES files(folder, download_filename)
);
"""
+
+create_hash_index = """
+CREATE INDEX IF NOT EXISTS idx_hash_type_hash ON hash (hash_type, hash);
+"""
diff --git a/cyberdrop_dl/database/tables/hash.py b/cyberdrop_dl/database/tables/hash.py
index 76808b4a8..cc7c7f346 100644
--- a/cyberdrop_dl/database/tables/hash.py
+++ b/cyberdrop_dl/database/tables/hash.py
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, cast
from cyberdrop_dl.utils.logger import log
-from .definitions import create_files, create_hash
+from .definitions import create_files, create_hash, create_hash_index
if TYPE_CHECKING:
import aiosqlite
@@ -23,9 +23,10 @@ class HashTable:
return self._database._db_conn
async def startup(self) -> None:
- """Startup process for the HistoryTable."""
+ """Startup process for the HashTable."""
await self.db_conn.execute(create_files)
await self.db_conn.execute(create_hash)
+ await self.db_conn.execute(create_hash_index)
await self.db_conn.commit()
async def get_file_hash_exists(self, path: Path | str, hash_type: str) -> str | None: