diff options
author | Maxim Pimenov <m@maps.me> | 2019-02-12 18:07:45 +0300 |
---|---|---|
committer | Vlad Mihaylenko <vxmihaylenko@gmail.com> | 2019-02-14 19:19:05 +0300 |
commit | f328e875d9623c4f5fbbac987a9ed6857e5f554b (patch) | |
tree | 3ca760bda5d4f134db8fa09d29565671bc6ce4f0 /storage | |
parent | 6e096f61060e521413774bd96a9c6a038a697998 (diff) |
[storage] Removing the deleted country from DiffManager.
Suppose that a user has one mwm and the app has been updated.
It now offers to download the diff, however instead
the user deletes the map and tries to download it again.
The download fails because according to the DiffManager it's
not the mwm but the mwmdiff that should be downloaded which
results in a size mismatch. Moreover, if the download is retried,
the diff is downloaded (because the MapOptions are correct now)
but it cannot be applied because the old mwm has already been removed.
The problem is that we do not account for the change in mwm status
since the start of the application (and, in particular, the DiffManager)
when taking the decision whether to download a diff or a full mwm.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/diff_scheme/diff_manager.cpp | 6 | ||||
-rw-r--r-- | storage/diff_scheme/diff_manager.hpp | 1 | ||||
-rw-r--r-- | storage/storage.cpp | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/storage/diff_scheme/diff_manager.cpp b/storage/diff_scheme/diff_manager.cpp index 9f4e78cf46..797719a01b 100644 --- a/storage/diff_scheme/diff_manager.cpp +++ b/storage/diff_scheme/diff_manager.cpp @@ -173,6 +173,12 @@ void Manager::RemoveAppliedDiffs() m_status = Status::NotAvailable; } +void Manager::RemoveDiffForCountry(storage::CountryId const & countryId) +{ + std::lock_guard<std::mutex> lock(m_mutex); + m_diffs.erase(countryId); +} + void Manager::AbortDiffScheme() { std::lock_guard<std::mutex> lock(m_mutex); diff --git a/storage/diff_scheme/diff_manager.hpp b/storage/diff_scheme/diff_manager.hpp index 407b251c35..fbe075695d 100644 --- a/storage/diff_scheme/diff_manager.hpp +++ b/storage/diff_scheme/diff_manager.hpp @@ -61,6 +61,7 @@ public: bool HasDiffFor(storage::CountryId const & countryId) const; void RemoveAppliedDiffs(); + void RemoveDiffForCountry(storage::CountryId const & countryId); void AbortDiffScheme(); Status GetStatus() const; diff --git a/storage/storage.cpp b/storage/storage.cpp index 061515df24..04dd45b419 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -571,6 +571,8 @@ void Storage::DeleteCountry(CountryId const & countryId, MapOptions opt) bool const deferredDelete = m_willDelete(countryId, localFile); DeleteCountryFiles(countryId, opt, deferredDelete); DeleteCountryFilesFromDownloader(countryId); + m_diffManager.RemoveDiffForCountry(countryId); + NotifyStatusChangedForHierarchy(countryId); } |