[new downloader] Refactor Storage::DownloadNode

This commit is contained in:
Sergey Yershov 2016-02-24 14:59:15 +03:00
parent 4d83bb1a32
commit 19b35b6224
2 changed files with 13 additions and 14 deletions

View file

@ -1188,23 +1188,22 @@ bool Storage::IsNodeDownloaded(TCountryId const & countryId) const
return false;
}
bool Storage::DownloadNode(TCountryId const & countryId)
void Storage::DownloadNode(TCountryId const & countryId)
{
ASSERT_THREAD_CHECKER(m_threadChecker, ());
// @TODO(bykoianko) Before downloading it's necessary to check if file(s) has been downloaded.
// If so, the method should be left with false.
TCountriesContainer const * const node = m_countries.FindFirst(Country(countryId));
CHECK(node, ());
node->ForEachInSubtree([this](TCountriesContainer const & descendantNode)
{
if (descendantNode.ChildrenCount() == 0)
{
this->DownloadCountry(descendantNode.Value().Name(),
MapOptions::MapWithCarRouting);
}
});
return true;
if (!node)
return;
auto downloadAction = [this](TCountriesContainer const & descendantNode)
{
if (descendantNode.ChildrenCount() == 0)
this->DownloadCountry(descendantNode.Value().Name(), MapOptions::MapWithCarRouting);
};
node->ForEachInSubtree(downloadAction);
}
void Storage::DeleteNode(TCountryId const & countryId)

View file

@ -277,7 +277,7 @@ public:
/// \brief Downloads one node (expandable or not) by countryId.
/// If node is expandable downloads all children (grandchildren) by the node
/// until they havn't been downloaded before. Update all downloaded mwm if it's necessary.
bool DownloadNode(TCountryId const & countryId);
void DownloadNode(TCountryId const & countryId);
/// \brief Delete node with all children (expandable or not).
void DeleteNode(TCountryId const & countryId);