1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

db: guard against no DB

Maybe if we only use `/connect` we dont have ProfAccount. In that case
we won't log anything. Only if a account is used we log.

If this is the case or the init of the db didn't work we still want
profanity to run but wont log anything to the db.
This commit is contained in:
Michael Vetter 2020-03-23 12:23:21 +01:00
parent 11663625cc
commit 1155963c6c

View File

@ -123,12 +123,20 @@ log_database_init(ProfAccount *account)
void
log_database_close(void)
{
sqlite3_close(g_chatlog_database);
sqlite3_shutdown();
if (g_chatlog_database) {
sqlite3_close(g_chatlog_database);
sqlite3_shutdown();
g_chatlog_database = NULL;
}
}
void
log_database_add(ProfMessage *message, gboolean is_muc) {
if (!g_chatlog_database) {
log_debug("log_database_add() called but db is not initialized");
return;
}
char *err_msg;
char *query;