From b34737a562990b5bf06d05531bef1fd664c0b2f3 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 16 Sep 2019 22:01:55 +0300 Subject: [PATCH] Close broken database before destroying. GitOrigin-RevId: ed3729139c843caba7d54e02d80262d4fccb81ef --- td/telegram/TdDb.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index b452c544a..1ff7686d5 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -418,6 +418,9 @@ Status TdDb::init(int32 scheduler_id, const TdParameters ¶meters, DbKey key, VLOG(td_init) << "Finish to init database"; if (init_sqlite_status.is_error()) { LOG(ERROR) << "Destroy bad SQLite database because of " << init_sqlite_status; + if (sql_connection_ != nullptr) { + sql_connection_->get().close(); + } SqliteDb::destroy(get_sqlite_path(parameters)).ignore(); TRY_STATUS(init_sqlite(scheduler_id, parameters, new_sqlite_key, old_sqlite_key, *binlog_pmc)); }