Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix create hash table columns
datawhores656cd0943ddb
diff --git a/cyberdrop_dl/utils/database/tables/hash_table.py b/cyberdrop_dl/utils/database/tables/hash_table.pyindex 6440594f6..802668e80 100644--- a/cyberdrop_dl/utils/database/tables/hash_table.py+++ b/cyberdrop_dl/utils/database/tables/hash_table.py@@ -15,9 +15,30 @@ class HashTable:async def startup(self) -> None:"""Startup process for the HistoryTable"""await self.db_conn.execute(create_hash)+ await self.add_columns_hash()await self.db_conn.commit()+ async def add_columns_hash(self) -> None:+ cursor = await self.db_conn.cursor()+ result = await cursor.execute("""pragma table_info(hash)""")+ result = await result.fetchall()+ current_cols = [col[1] for col in result]++ if "download_filename" not in current_cols:+ await self.db_conn.execute("""ALTER TABLE hash RENAME COLUMN filename TO download_filename;""")+ await self.db_conn.commit()++ if "file_size" not in current_cols:+ await self.db_conn.execute("""ALTER TABLE hash RENAME COLUMN size TO file_size;""")+ await self.db_conn.commit()++ if "original_filename" not in current_cols:+ await self.db_conn.execute("""ALTER TABLE hash ADD COLUMN original_filename TEXT""")+ await self.db_conn.commit()+ if "referer" not in current_cols:+ await self.db_conn.execute("""ALTER TABLE hash ADD COLUMN referer TEXT""")+ await self.db_conn.commit()async def get_file_hash_exists(self, full_path):"""Checks if a file exists in the database based on its folder, filename, and size.diff --git a/cyberdrop_dl/utils/database/tables/history_table.py b/cyberdrop_dl/utils/database/tables/history_table.pyindex 4545ccb94..7365e6c2b 100644--- a/cyberdrop_dl/utils/database/tables/history_table.py+++ b/cyberdrop_dl/utils/database/tables/history_table.py@@ -47,7 +47,6 @@ class HistoryTable:await self.db_conn.commit()await self.fix_primary_keys()await self.add_columns_media()- await self.add_columns_hash()await self.fix_bunkr_v4_entries()async def check_complete(self, domain: str, url: URL, referer: URL) -> bool:@@ -258,25 +257,3 @@ class HistoryTable:if "file_size" not in current_cols:await self.db_conn.execute("""ALTER TABLE media ADD COLUMN file_size INT""")await self.db_conn.commit()-- async def add_columns_hash(self) -> None:- cursor = await self.db_conn.cursor()- result = await cursor.execute("""pragma table_info(hash)""")- result = await result.fetchall()- current_cols = [col[1] for col in result]-- if "download_filename" not in current_cols:- await self.db_conn.execute("""ALTER TABLE hash RENAME COLUMN filename TO download_filename;""")- await self.db_conn.commit()-- if "file_size" not in current_cols:- await self.db_conn.execute("""ALTER TABLE hash RENAME COLUMN size TO file_size;""")- await self.db_conn.commit()-- if "original_filename" not in current_cols:- await self.db_conn.execute("""ALTER TABLE hash ADD COLUMN original_filename TEXT""")- await self.db_conn.commit()-- if "referer" not in current_cols:- await self.db_conn.execute("""ALTER TABLE hash ADD COLUMN referer TEXT""")- await self.db_conn.commit()\ No newline at end of file