diff --git a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm index eca21af4c5..f3d5813f30 100644 --- a/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm +++ b/iphone/Maps/Classes/MapDownloader/Cells/MWMMapDownloaderTableViewCell.mm @@ -81,7 +81,7 @@ namespace self.downloadSize.text = formattedSize(haveDownloadingCountries ? nodeAttrs.m_downloadingMwmSize : nodeAttrs.m_mwmSize); } -- (void)configProgress:(const storage::NodeAttrs &)nodeAttrs +- (void)configProgress:(storage::NodeAttrs const &)nodeAttrs { MWMCircularProgress * progress = self.progress; switch (nodeAttrs.m_status) diff --git a/iphone/Maps/Classes/MapDownloader/DataSources/MWMMapDownloaderExtendedDataSource.mm b/iphone/Maps/Classes/MapDownloader/DataSources/MWMMapDownloaderExtendedDataSource.mm index 84fe3208e9..d9693aa68e 100644 --- a/iphone/Maps/Classes/MapDownloader/DataSources/MWMMapDownloaderExtendedDataSource.mm +++ b/iphone/Maps/Classes/MapDownloader/DataSources/MWMMapDownloaderExtendedDataSource.mm @@ -41,7 +41,8 @@ using namespace storage; [super reload]; NSInteger const closestCoutriesCountAfterUpdate = self.nearmeCountries.count; - if (closestCoutriesCountBeforeUpdate == 0 || closestCoutriesCountAfterUpdate == 0) + if (closestCoutriesCountBeforeUpdate != closestCoutriesCountAfterUpdate && + (closestCoutriesCountBeforeUpdate == 0 || closestCoutriesCountAfterUpdate == 0)) self.needFullReload = YES; if (self.needFullReload) return; diff --git a/storage/storage.cpp b/storage/storage.cpp index 155541fd87..41a38d11ee 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -666,8 +666,8 @@ void Storage::OnMapFileDownloadFinished(bool success, CorrectJustDownloadedAndQueue(m_queue.begin()); SaveDownloadQueue(); - NotifyStatusChangedForHierarchy(countryId); m_downloader->Reset(); + NotifyStatusChangedForHierarchy(countryId); DownloadNextCountryFromQueue(); } @@ -1435,6 +1435,8 @@ MapFilesDownloader::TProgress Storage::CalculateProgress(TCountryId const & down MapFilesDownloader::TProgress const & downloadingMwmProgress, TCountriesSet const & mwmsInQueue) const { + // Function calculates progress correctly OLNY if |downloadingMwm| is leaf. + MapFilesDownloader::TProgress localAndRemoteBytes = make_pair(0, 0); for (auto const & d : mwms) @@ -1442,18 +1444,13 @@ MapFilesDownloader::TProgress Storage::CalculateProgress(TCountryId const & down if (downloadingMwm == d && downloadingMwm != kInvalidCountryId) { localAndRemoteBytes.first += downloadingMwmProgress.first; - localAndRemoteBytes.second += downloadingMwmProgress.second; - continue; + localAndRemoteBytes.second += GetCountryFile(d).GetRemoteSize(MapOptions::Map); } - - if (mwmsInQueue.count(d) != 0) + else if (mwmsInQueue.count(d) != 0) { - CountryFile const & remoteCountryFile = GetCountryFile(d); - localAndRemoteBytes.second += remoteCountryFile.GetRemoteSize(MapOptions::Map); - continue; + localAndRemoteBytes.second += GetCountryFile(d).GetRemoteSize(MapOptions::Map); } - - if (m_justDownloaded.count(d) != 0) + else if (m_justDownloaded.count(d) != 0) { size_t const localCountryFileSz = GetCountryFile(d).GetRemoteSize(MapOptions::Map); localAndRemoteBytes.first += localCountryFileSz; diff --git a/storage/storage.hpp b/storage/storage.hpp index c6ab1a2cf6..3f096121c6 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -579,6 +579,7 @@ private: /// Calculates progress of downloading for expandable nodes in country tree. /// |descendants| All descendants of the parent node. /// |downloadingMwm| Downloading leaf node country id if any. If not, downloadingMwm == kInvalidCountryId. + /// |downloadingMwm| Must be only leaf. /// If downloadingMwm != kInvalidCountryId |downloadingMwmProgress| is a progress of downloading /// the leaf node in bytes. |downloadingMwmProgress.first| == number of downloaded bytes. /// |downloadingMwmProgress.second| == number of bytes in downloading files.