aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-07-03 15:21:28 +0300
committerBonfaceKilz2024-07-03 16:53:31 +0300
commit52cd294c2f1d06dddbd6ff613b11f8bc43066038 (patch)
treeafb95e85718867209af1d6570dfd9f79c7795ae8 /scripts
parent4fd5710dc04b51c0953a2063d9e934dddc13ad6c (diff)
downloadgenenetwork3-52cd294c2f1d06dddbd6ff613b11f8bc43066038.tar.gz
Return a "-1" if the turtle directory does not exist.
* scripts/index-genenetwork (hash_rdf_graph): Remove check for the turtle directory. (is_data_modified): Ditto. (create_xapian_index): Ditto. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/index-genenetwork13
1 files changed, 6 insertions, 7 deletions
diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork
index de3edb0..c13c933 100755
--- a/scripts/index-genenetwork
+++ b/scripts/index-genenetwork
@@ -241,6 +241,8 @@ def build_rdf_cache(sparql_uri: str, query: str, remove_common_words: bool = Fal
def hash_rdf_graph(ttl_dir: pathlib.Path) -> str:
+ if not ttl_dir.exists():
+ return "-1"
ttl_hash = hashlib.new("md5")
for ttl_file in ttl_dir.glob("*.ttl"):
with open(ttl_file, encoding="utf-8") as f_:
@@ -528,10 +530,7 @@ def is_data_modified(xapian_directory: str,
# Return a zero exit status code when the data has changed;
# otherwise exit with a 1 exit status code.
generif = pathlib.Path("/var/lib/data/generif-metadata.ttl")
- generif_checksum = "-1"
- if generif.exists():
- generif_checksum = hash_rdf_graph(generif)
- if (db.get_metadata("generif-checksum").decode() == generif_checksum and
+ if (db.get_metadata("generif-checksum").decode() == hash_rdf_graph(generif) and
db.get_metadata("checksums").decode() == checksums):
sys.exit(1)
sys.exit(0)
@@ -586,9 +585,9 @@ def create_xapian_index(xapian_directory: str, sql_uri: str,
db.set_metadata("tables", " ".join(tables))
db.set_metadata("checksums", " ".join(checksums))
logging.info("Writing generif checksums into index")
- generif = pathlib.Path("/var/lib/data/generif-metadata.ttl")
- if generif.exists():
- db.set_metadata("generif-checksum", hash_rdf_graph(generif).encode())
+ db.set_metadata(
+ "generif-checksum",
+ hash_rdf_graph(pathlib.Path("/var/lib/data/generif-metadata.ttl")).encode())
for child in combined_index.iterdir():
shutil.move(child, xapian_directory)
logging.info("Index built")