Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hash-db-error-fix #407

Merged
merged 3 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ venv

# MacOS system files
**.DS_Store
.aider*
.env
9 changes: 8 additions & 1 deletion cyberdrop_dl/utils/transfer/transfer_hash_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

console = Console()


def transfer_from_old_hash_table(db_path):
"""Transfers data from the old 'hash' table to new 'files' and 'temp_hash' tables, handling potential schema differences and errors.

Expand All @@ -23,6 +22,14 @@ def transfer_from_old_hash_table(db_path):
"""

with db_transfer_context(db_path) as cursor:
# Check if the 'hash' table exists
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='hash'")
hash_table_exists = cursor.fetchone() is not None

if not hash_table_exists:
console.print("[bold yellow]Old 'hash' table not found. Skipping transfer.[/]")
return

# Check if the 'hash_type' column exists in the 'hash' table
cursor.execute("SELECT COUNT(*) FROM pragma_table_info('hash') WHERE name='hash_type'")
has_hash_type_column = (cursor.fetchone())[0] > 0
Expand Down