Skip to content

Bulk asynchronous downloader for multiple file hosts

fix insert error on new hash table

datawhoresc2ee69e26a85
diff --git a/cyberdrop_dl/clients/hash_client.py b/cyberdrop_dl/clients/hash_client.py
index 846d60634..94c6fa762 100644
--- a/cyberdrop_dl/clients/hash_client.py
+++ b/cyberdrop_dl/clients/hash_client.py
@@ -123,10 +123,12 @@ class HashClient:
# Filter out files with the same path as any file in other_files
filtered_matches = [match for match in all_matches if str(match) not in other_files]
#Filter files based on if the file exists
- filtered_matches = list(filter(lambda x: x.exists(),filtered_matches ))
-
+ filtered_matches = list(filter(lambda x: x.exists(),filtered_matches ))
+
#what do do with prev matches and current file
- if not self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_prev_download']:
+ if len(filtered_matches) == 0:
+ pass
+ elif not self.manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_prev_download']:
for ele in filtered_matches:
if not ele.exists():
continue
diff --git a/cyberdrop_dl/utils/database/tables/hash_table.py b/cyberdrop_dl/utils/database/tables/hash_table.py
index 4c33091d9..565b42fbe 100644
--- a/cyberdrop_dl/utils/database/tables/hash_table.py
+++ b/cyberdrop_dl/utils/database/tables/hash_table.py
@@ -71,7 +71,7 @@ class HashTable:
return []
- async def insert_or_update_hash_db(self, hash_value, file,original_filename,refer):
+ async def insert_or_update_hash_db(self, hash_value, file,original_filename,referer):
"""
Inserts or updates a record in the specified SQLite database.
@@ -95,7 +95,7 @@ class HashTable:
# Assuming a table named 'file_info' with columns: id (primary key), hash, size, filename, folder
try:
await cursor.execute("INSERT INTO hash (hash, size, download_filename, folder,original_filename,referer) VALUES (?, ?, ?, ?,?,?)",
- (hash_value, file_size, download_filename, folder,original_filename,refer))
+ (hash_value, file_size, download_filename, folder,original_filename,referer))
await self.db_conn.commit()
return True
except IntegrityError:
@@ -103,10 +103,10 @@ class HashTable:
await cursor.execute("""UPDATE hash
SET size = ?,
hash = ?,
- referer = CASE WHEN ? IS NOT NULL THEN ? ELSE referer END,
+ referer= CASE WHEN ? IS NOT NULL THEN ? ELSE referer END,
original_filename = CASE WHEN ? IS NOT NULL THEN ? ELSE original_filename END
WHERE download_filename = ? AND folder = ?;""",
- (file_size,hash_value,refer,original_filename, download_filename, folder))
+ (file_size,hash_value,referer,referer,original_filename,original_filename,download_filename,folder))
await self.db_conn.commit()
return True
except Exception as e: