Flush DialogDb on closing.

This commit is contained in:
levlam 2022-11-10 19:20:17 +03:00
parent 8e32de133a
commit f78bf4005e
4 changed files with 15 additions and 1 deletions

View File

@ -377,6 +377,10 @@ class DialogDbAsync final : public DialogDbAsyncInterface {
send_closure_later(impl_, &Impl::close, std::move(promise));
}
void force_flush() final {
send_closure_later(impl_, &Impl::force_flush);
}
private:
class Impl final : public Actor {
public:
@ -432,6 +436,11 @@ class DialogDbAsync final : public DialogDbAsyncInterface {
stop();
}
void force_flush() {
do_flush();
LOG(INFO) << "DialogDb flushed";
}
private:
std::shared_ptr<DialogDbSyncSafeInterface> sync_db_safe_;
DialogDbSyncInterface *sync_db_ = nullptr;

View File

@ -93,6 +93,8 @@ class DialogDbAsyncInterface {
virtual void get_secret_chat_count(FolderId folder_id, Promise<int32> promise) = 0;
virtual void close(Promise<Unit> promise) = 0;
virtual void force_flush() = 0;
};
Status init_dialog_db(SqliteDb &db, int version, KeyValueSyncInterface &binlog_pmc,

View File

@ -1199,8 +1199,8 @@ class MessageDbAsync final : public MessageDbAsyncInterface {
}
void force_flush() {
LOG(INFO) << "MessageDb flushed";
do_flush();
LOG(INFO) << "MessageDb flushed";
}
private:

View File

@ -209,6 +209,9 @@ void TdDb::flush_all() {
if (message_db_async_) {
message_db_async_->force_flush();
}
if (dialog_db_async_) {
dialog_db_async_->force_flush();
}
binlog_->force_flush();
}