From a62798d0f59e953dbeba69f370f8d8045bd4becf Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 10 Jun 2024 23:23:10 +0300 Subject: Add method to check the validity of the tables+RDF checksums. * scripts/index-genenetwork (verify_checksums): New function. Signed-off-by: Munyoki Kilyungi --- scripts/index-genenetwork | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'scripts/index-genenetwork') diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork index 52a48df..f291f6b 100755 --- a/scripts/index-genenetwork +++ b/scripts/index-genenetwork @@ -448,6 +448,20 @@ def xapian_compact(combined_index: pathlib.Path, indices: List[pathlib.Path]) -> db.close() +def verify_checksums(xapian_directory: str, + sql_uri: str) -> bool: + dir_ = pathlib.Path(xapian_directory) + with locked_xapian_writable_database(dir_) as db, database_connection(sql_uri) as conn: + checksums = " ".join([ + result["Checksum"].bind(str) + for result in query_sql( + conn, + f"CHECKSUM TABLE {', '.join(db.get_metadata('tables').decode().split())}") + ]) + return (db.get_metadata("generif-checksum").decode() == hash_generif_graph() and + db.get_metadata("checksums").decode() == checksums) + + @click.command(help="Index GeneNetwork data and build Xapian search index in XAPIAN_DIRECTORY.") @click.argument("xapian_directory") @click.argument("sql_uri") -- cgit v1.2.3