From fc684f65711757846fda30b2f9779feade8f8912 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Fri, 21 Sep 2018 14:43:52 +0300 Subject: [PATCH] Require login when the cache format changes (regression on #444) --- src/Cache.cpp | 4 ++-- src/ChatPage.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Cache.cpp b/src/Cache.cpp index c720a537..372dd44a 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -32,7 +32,7 @@ //! Should be changed when a breaking change occurs in the cache format. //! This will reset client's data. -static const std::string CURRENT_CACHE_FORMAT_VERSION("2018.09.16"); +static const std::string CURRENT_CACHE_FORMAT_VERSION("2018.09.21"); static const std::string SECRET("secret"); static const lmdb::val NEXT_BATCH_KEY("next_batch"); @@ -673,7 +673,7 @@ Cache::isFormatValid() txn.commit(); if (!res) - return true; + return false; std::string stored_version(current_version.data(), current_version.size()); diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 53bed40f..3a534df1 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -683,8 +683,9 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) const bool isInitialized = cache::client()->isInitialized(); const bool isValid = cache::client()->isFormatValid(); - if (isInitialized && !isValid) { - nhlog::db()->warn("breaking changes in cache"); + if (!isInitialized) { + cache::client()->setCurrentFormat(); + } else if (isInitialized && !isValid) { // TODO: Deleting session data but keep using the // same device doesn't work. cache::client()->deleteData(); @@ -975,7 +976,7 @@ ChatPage::tryInitialSync() status_code); QString errorMsg(tr("Failed to setup encryption keys. Server response: " - "%s %d. Please try again later.") + "%1 %2. Please try again later.") .arg(QString::fromStdString(err->matrix_error.error)) .arg(status_code));