From 0dbc21adc491dd5c0504ee198d484d456cfa4aff Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Wed, 18 Sep 2019 19:30:45 +0300 Subject: [PATCH] [storage] got rid m_localMapsInfo member from diff manager --- storage/diff_scheme/diff_manager.cpp | 19 +------------------ storage/diff_scheme/diff_manager.hpp | 2 -- storage/storage.cpp | 21 ++++++++++++++++++++- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/storage/diff_scheme/diff_manager.cpp b/storage/diff_scheme/diff_manager.cpp index beb2e16928..edd9d70495 100644 --- a/storage/diff_scheme/diff_manager.cpp +++ b/storage/diff_scheme/diff_manager.cpp @@ -27,10 +27,7 @@ namespace diffs { void Manager::Load(LocalMapsInfo && info) { - LocalMapsInfo localMapsInfo = info; - m_localMapsInfo = std::move(info); - - GetPlatform().RunTask(Platform::Thread::Network, [this, info = std::move(localMapsInfo)] { + GetPlatform().RunTask(Platform::Thread::Network, [this, info = std::move(info)] { NameDiffInfoMap diffs = Checker::Check(info); GetPlatform().RunTask(Platform::Thread::Gui, [this, diffs = std::move(diffs)] { @@ -181,19 +178,5 @@ void Manager::AbortDiffScheme() m_status = Status::NotAvailable; m_diffs.clear(); } - -bool Manager::IsPossibleToAutoupdate() const -{ - if (m_status != Status::Available) - return false; - - for (auto const & nameVersion : m_localMapsInfo.m_localMaps) - { - auto const it = m_diffs.find(nameVersion.first); - if (it == m_diffs.cend() || it->second.m_isApplied) - return false; - } - return true; -} } // namespace diffs } // namespace storage diff --git a/storage/diff_scheme/diff_manager.hpp b/storage/diff_scheme/diff_manager.hpp index 04269315e4..1f2487670a 100644 --- a/storage/diff_scheme/diff_manager.hpp +++ b/storage/diff_scheme/diff_manager.hpp @@ -54,7 +54,6 @@ public: bool SizeToDownloadFor(storage::CountryId const & countryId, uint64_t & size) const; bool VersionFor(storage::CountryId const & countryId, uint64_t & version) const; - bool IsPossibleToAutoupdate() const; // Checks whether the diff for |countryId| is available for download or // has been downloaded. @@ -90,7 +89,6 @@ private: Status m_status = Status::Undefined; NameDiffInfoMap m_diffs; - LocalMapsInfo m_localMapsInfo; base::ObserverListUnsafe m_observers; }; } // namespace diffs diff --git a/storage/storage.cpp b/storage/storage.cpp index 7e2b2d8c3e..daa8f70b0d 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1617,7 +1617,26 @@ void Storage::ApplyDiff(CountryId const & countryId, functionGetVersion(); + if (mapVersion != currentVersion && mapVersion > 0 && + !m_diffManager.HasDiffFor(localFile->GetCountryName())) + { + isPossibleToAutoupdate = false; + break; + } + } + + return isPossibleToAutoupdate; } void Storage::SetStartDownloadingCallback(StartDownloadingCallback const & cb)