From 41ed585aa2c40cfb9e7eacd75e9c0bb2257c349f Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 8 Oct 2018 16:29:44 +0300 Subject: [PATCH] Fix deleting old data when database is dropped. GitOrigin-RevId: 0dae9d82c02bf3f45d3ebd37b86e5765887020b3 --- td/telegram/TdDb.cpp | 8 ++++---- td/telegram/Version.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index 92a53e8f1..5bd515150 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -277,7 +277,7 @@ Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters ¶meters, DbK // Get 'PRAGMA user_version' TRY_RESULT(user_version, db.user_version()); - LOG(WARNING) << "got PRAGMA user_version = " << user_version; + LOG(WARNING) << "Got PRAGMA user_version = " << user_version; // init DialogDb bool dialog_db_was_created = false; @@ -304,7 +304,7 @@ Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters ¶meters, DbK // Update 'PRAGMA user_version' auto db_version = current_db_version(); if (db_version != user_version) { - LOG(WARNING) << "set PRAGMA user_version = " << db_version; + LOG(WARNING) << "Set PRAGMA user_version = " << db_version; TRY_STATUS(db.set_user_version(db_version)); } @@ -314,9 +314,9 @@ Status TdDb::init_sqlite(int32 scheduler_id, const TdParameters ¶meters, DbK binlog_pmc.erase("last_server_dialog_date"); binlog_pmc.erase("promoted_dialog_id"); binlog_pmc.erase("sponsored_dialog_id"); - } - if (db_version == 0) { binlog_pmc.erase_by_prefix("top_dialogs"); + } + if (user_version == 0) { binlog_pmc.erase("next_contacts_sync_date"); } binlog_pmc.force_sync({}); diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 3ae8df9d2..a180aac32 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -39,7 +39,7 @@ enum class DbVersion : int32 { Next }; -inline int32 current_db_version() { +inline constexpr int32 current_db_version() { return static_cast(DbVersion::Next) - 1; }