diff options
author | Munyoki Kilyungi | 2024-06-10 23:23:10 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-06-12 19:21:50 +0300 |
commit | a62798d0f59e953dbeba69f370f8d8045bd4becf (patch) | |
tree | cb7d5d9def8d8f9f9634d50ba23c36c86ad13576 /scripts/index-genenetwork | |
parent | 4d82124fcd243ae0b8da8ca4706e73e407a67c02 (diff) | |
download | genenetwork3-a62798d0f59e953dbeba69f370f8d8045bd4becf.tar.gz |
Add method to check the validity of the tables+RDF checksums.
* scripts/index-genenetwork (verify_checksums): New function.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'scripts/index-genenetwork')
-rwxr-xr-x | scripts/index-genenetwork | 14 |
1 files changed, 14 insertions, 0 deletions
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") |