diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2017-09-13 11:40:45 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2017-09-13 16:25:40 +0300 |
commit | 9cc1fb3862a0dce5f418f4abe22a657ea93278f8 (patch) | |
tree | 405dae1ef0391ab140d3ba06ca96c693623ef392 /storage | |
parent | b36f653eafe30046ceeb4a2608fa2eb25383b21d (diff) |
Fixed download failure notification
Diffstat (limited to 'storage')
-rw-r--r-- | storage/storage.cpp | 18 | ||||
-rw-r--r-- | storage/storage.hpp | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/storage/storage.cpp b/storage/storage.cpp index 7d282fad9f..7263d30dc0 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -825,8 +825,7 @@ void Storage::RegisterDownloadedFiles(TCountryId const & countryId, MapOptions o ASSERT_THREAD_CHECKER(m_threadChecker, ()); if (!isSuccess) { - m_failedCountries.insert(countryId); - NotifyStatusChangedForHierarchy(countryId); + OnDownloadFailed(countryId); return; } @@ -907,8 +906,7 @@ void Storage::OnMapDownloadFinished(TCountryId const & countryId, bool success, if (!success) { - m_failedCountries.insert(countryId); - NotifyStatusChangedForHierarchy(countryId); + OnDownloadFailed(countryId); return; } @@ -1452,8 +1450,7 @@ void Storage::OnDiffStatusReceived(diffs::Status const status) ASSERT_THREAD_CHECKER(m_threadChecker, ()); if (!isSuccess) { - m_failedCountries.insert(countryId); - NotifyStatusChangedForHierarchy(countryId); + OnDownloadFailed(countryId); return; } @@ -1884,4 +1881,13 @@ TMwmSize Storage::GetRemoteSize(CountryFile const & file, MapOptions opt, int64_ } return size; } + +void Storage::OnDownloadFailed(TCountryId const & countryId) +{ + m_failedCountries.insert(countryId); + auto it = find(m_queue.cbegin(), m_queue.cend(), countryId); + if (it != m_queue.cend()) + m_queue.erase(it); + NotifyStatusChangedForHierarchy(countryId); +} } // namespace storage diff --git a/storage/storage.hpp b/storage/storage.hpp index 483860eec2..3e95c538ba 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -656,6 +656,8 @@ private: bool IsDisputed(TCountryTreeNode const & node) const; void CalMaxMwmSizeBytes(); + + void OnDownloadFailed(TCountryId const & countryId); void LoadDiffScheme(); void ApplyDiff(TCountryId const & countryId, function<void(bool isSuccess)> const & fn); |