Skip to content

Commit

Permalink
commands.init:check_import_db - safer check for metadata table
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Dec 18, 2024
1 parent beb7bae commit 9db8940
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion digiarch/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def check_import_db(
tables: list[str] = [t.lower() for [t] in db_old.execute("select name from sqlite_master where type = 'table'")]
if "files" not in tables:
raise BadParameter("Invalid database schema.", ctx, ctx_params(ctx)[import_param_name])
if "metadata" not in tables:
if "metadata" not in tables or (
{c.lower() for [_, c, *_] in db_old.execute("pragma table_info(metadata)")} != {"key", "value"}
):
return "files"

version = db_old.execute("select value from Metadata where key = 'version'").fetchone()
Expand Down

0 comments on commit 9db8940

Please sign in to comment.