From 5bcc289583629634b14a4a64ff80ac2ff415589b Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 17 Jun 2024 17:15:42 +0300 Subject: Check table names in Xapian; if not, default to "-1". Without this check, there will always be an error when this script is run with the "is-data-modified" flag should there be no database in the XAPIAN_DIRECTORY. Signed-off-by: Munyoki Kilyungi --- scripts/index-genenetwork | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork index 4d9a5f8..61780e5 100755 --- a/scripts/index-genenetwork +++ b/scripts/index-genenetwork @@ -461,12 +461,14 @@ def is_data_modified(xapian_directory: str, sparql_uri: str) -> None: dir_ = pathlib.Path(xapian_directory) with locked_xapian_writable_database(dir_) as db, database_connection(sql_uri) as conn: - checksums = " ".join([ - str(result["Checksum"].value) - for result in query_sql( - conn, - f"CHECKSUM TABLE {', '.join(db.get_metadata('tables').decode().split())}") - ]) + checksums = -1 + if db.get_metadata('tables'): + checksums = " ".join([ + str(result["Checksum"].value) + for result in query_sql( + conn, + f"CHECKSUM TABLE {', '.join(db.get_metadata('tables').decode().split())}") + ]) # Return a zero exit status code when the data has changed; # otherwise exit with a 1 exit status code. if (db.get_metadata("generif-checksum").decode() == hash_generif_graph(sparql_uri) and -- cgit v1.2.3