[omim] Fixed Storage CalculateProgress.

This commit is contained in:
Ilya Grechuhin 2016-04-11 12:54:50 +03:00
parent 0d031b8266
commit b7ca4a7aa7
2 changed files with 8 additions and 10 deletions

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.