aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-06-17 17:15:42 +0300
committerBonfaceKilz2024-06-17 17:32:05 +0300
commit5bcc289583629634b14a4a64ff80ac2ff415589b (patch)
tree8d377345ab6ec8cfc22094ed6c9726524c44d248 /scripts
parenta167c4b6112f97f0352488712c58eeb0679219b2 (diff)
downloadgenenetwork3-5bcc289583629634b14a4a64ff80ac2ff415589b.tar.gz
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 <me@bonfacemunyoki.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/index-genenetwork14
1 files 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