diff --git a/storage/diff_scheme/diff_manager.hpp b/storage/diff_scheme/diff_manager.hpp index a993498c6a..0d10c19569 100644 --- a/storage/diff_scheme/diff_manager.hpp +++ b/storage/diff_scheme/diff_manager.hpp @@ -41,7 +41,7 @@ public: }; using OnDiffApplicationFinished = - std::function; + std::function; // If the diff is available, sets |size| to its size and returns true. // Otherwise, returns false. diff --git a/storage/queued_country.hpp b/storage/queued_country.hpp index 31f0f99ad3..fb5028c258 100644 --- a/storage/queued_country.hpp +++ b/storage/queued_country.hpp @@ -21,9 +21,6 @@ public: void ResetToDefaultOptions(); bool SwitchToNextFile(); - void SetFrozen(bool isFrozen) { m_isFrozen = isFrozen; } - bool IsFrozen() const { return m_isFrozen; } - inline CountryId const & GetCountryId() const { return m_countryId; } inline MapOptions GetInitOptions() const { return m_init; } inline MapOptions GetCurrentFileOptions() const { return m_current; } diff --git a/storage/storage.cpp b/storage/storage.cpp index d3dc57c1c4..a9a1da3173 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -951,8 +951,6 @@ void Storage::RegisterDownloadedFiles(CountryId const & countryId, MapOptions op if (options == MapOptions::Diff) { - m_queue.begin()->SetFrozen(true); - NotifyStatusChangedForHierarchy(countryId); ApplyDiff(countryId, fn); return; } @@ -1171,7 +1169,7 @@ bool Storage::IsDiffApplyingInProgressToCountry(CountryId const & countryId) con if (!IsCountryFirstInQueue(countryId)) return false; - return m_queue.front().IsFrozen(); + return m_queue.front().GetCountryId() == m_latestDiffRequest; } void Storage::SetLocale(string const & locale) { m_countryNameGetter.SetLocale(locale); } @@ -1288,7 +1286,7 @@ bool Storage::DeleteCountryFilesFromDownloader(CountryId const & countryId) if (!queuedCountry) return false; - if (queuedCountry->IsFrozen()) + if (m_latestDiffRequest && m_latestDiffRequest == countryId) m_diffsCancellable.Cancel(); MapOptions const opt = queuedCountry->GetInitOptions(); @@ -1558,6 +1556,8 @@ void Storage::LoadDiffScheme() void Storage::ApplyDiff(CountryId const & countryId, function const & fn) { m_diffsCancellable.Reset(); + m_latestDiffRequest = countryId; + NotifyStatusChangedForHierarchy(countryId); diffs::Manager::ApplyDiffParams params; params.m_diffFile = @@ -1569,6 +1569,7 @@ void Storage::ApplyDiff(CountryId const & countryId, function m_latestDiffRequest; + DownloadingPolicy m_defaultDownloadingPolicy; DownloadingPolicy * m_downloadingPolicy = &m_defaultDownloadingPolicy;