aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/ocda/abstraction/db_in.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/ocda/abstraction/db_in.d')
-rw-r--r--src/sisudoc/ocda/abstraction/db_in.d28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/sisudoc/ocda/abstraction/db_in.d b/src/sisudoc/ocda/abstraction/db_in.d
index 0a01364..986a09d 100644
--- a/src/sisudoc/ocda/abstraction/db_in.d
+++ b/src/sisudoc/ocda/abstraction/db_in.d
@@ -90,6 +90,34 @@ template spineDbLanguages() {
return _out;
}
}
+/+ ↓ the .ssp digest a database recorded for each of its languages.
+ .
+ What verify holds its answer against: the database says which .ssp it was
+ built from, so re-parsing the markup it carries and emitting the .ssp again
+ either reproduces that digest or does not.
+ .
+ Its own template, for the reason spineDbLanguages is: asking a file what it
+ recorded should not instantiate the reader.
++/
+template spineDbSspDigests() {
+ @trusted string[string] spineDbSspDigests(string db_file) {
+ import std.file : exists;
+ import d2sqlite3;
+ string[string] _out;
+ if (!db_file.exists) { return _out; }
+ try {
+ auto db = Database(db_file, SQLITE_OPEN_READONLY);
+ foreach (row; db.execute(
+ "SELECT lang, ssp_digest FROM documents ORDER BY id")
+ ) {
+ _out[row["lang"].as!string] = row["ssp_digest"].as!string;
+ }
+ } catch (Exception ex) {
+ return string[string].init;
+ }
+ return _out;
+ }
+}
template spineAbstractionDbRead() {
import std.conv : to;
import std.file;