Slightly more honest startup messaging.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4001 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-10-12 13:04:45 +00:00
parent 656ab7beb6
commit 70866e03c8

View File

@ -107,10 +107,25 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
")");
_tf_ssb_db_exec(db, "CREATE INDEX IF NOT EXISTS identities_user ON identities (user, public_key)");
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_fts')") ||
sqlite3_exec(db, "INSERT INTO messages_fts(messages_fts, rank) VALUES ('integrity-check', 0)", NULL, NULL, NULL) == SQLITE_CORRUPT_VTAB)
bool populate_fts = false;
if (!_tf_ssb_db_has_rows(db, "PRAGMA table_list('messages_fts')"))
{
_tf_ssb_db_exec(db, "CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts USING fts5(content, content=messages, content_rowid=rowid)");
populate_fts = true;
}
if (!populate_fts)
{
printf("Checking FTS5 integrity...\n");
if (sqlite3_exec(db, "INSERT INTO messages_fts(messages_fts, rank) VALUES ('integrity-check', 0)", NULL, NULL, NULL) == SQLITE_CORRUPT_VTAB)
{
populate_fts = true;
}
printf("Done.\n");
}
if (populate_fts)
{
printf("Populating full-text search...\n");
_tf_ssb_db_exec(db, "INSERT INTO messages_fts (rowid, content) SELECT rowid, content FROM messages");
printf("Done.\n");