Merge pull request #2861 from igrechuhin/ig-master

[omim] Fixed Storage CalculateProgress.
This commit is contained in:
Sergey Yershov 2016-04-11 14:47:37 +04:00
commit 7ac842254c
4 changed files with 11 additions and 12 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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.