forked from organicmaps/organicmaps
[new downloader] Implementation of Storage::GetUpdateInfo().
This commit is contained in:
parent
a4186abc47
commit
101559e7ab
2 changed files with 24 additions and 1 deletions
|
@ -1418,4 +1418,25 @@ void Storage::RetryDownloadNode(TCountryId const & countryId)
|
|||
DownloadNode(descendantId);
|
||||
});
|
||||
}
|
||||
|
||||
bool Storage::GetUpdateInfo(TCountryId const & countryId, UpdateInfo & updateInfo) const
|
||||
{
|
||||
auto const updateInfoAccumulator = [&updateInfo, this](TCountryTreeNode const & descendantNode)
|
||||
{
|
||||
if (descendantNode.ChildrenCount() != 0 || GetNodeStatus(descendantNode).status != NodeStatus::OnDiskOutOfDate)
|
||||
return;
|
||||
updateInfo.m_numberOfMwmFilesToUpdate += 1; // It's not a group mwm.
|
||||
updateInfo.m_totalUpdateSizeInBytes += descendantNode.Value().GetSubtreeMwmCounter();
|
||||
};
|
||||
|
||||
TCountryTreeNode const * const node = m_countries.FindFirst(countryId);
|
||||
if (!node)
|
||||
{
|
||||
ASSERT(false, ());
|
||||
return false;
|
||||
}
|
||||
updateInfo = UpdateInfo();
|
||||
node->ForEachInSubtree(updateInfoAccumulator);
|
||||
return true;
|
||||
}
|
||||
} // namespace storage
|
||||
|
|
|
@ -251,6 +251,8 @@ public:
|
|||
/// \brief Information for "Update all mwms" button.
|
||||
struct UpdateInfo
|
||||
{
|
||||
UpdateInfo() : m_numberOfMwmFilesToUpdate(0), m_totalUpdateSizeInBytes(0) {}
|
||||
|
||||
size_t m_numberOfMwmFilesToUpdate;
|
||||
size_t m_totalUpdateSizeInBytes;
|
||||
};
|
||||
|
@ -330,7 +332,7 @@ public:
|
|||
|
||||
/// \brief Get information for mwm update button.
|
||||
/// \return true if updateInfo is filled correctly and false otherwise.
|
||||
bool GetUpdateInfo(TCountryId const & countryId, UpdateInfo & updateInfo) const { return true; }
|
||||
bool GetUpdateInfo(TCountryId const & countryId, UpdateInfo & updateInfo) const;
|
||||
|
||||
/// \brief Calls |toDo| for each node for subtree with |root|.
|
||||
/// For example ForEachInSubtree(GetRootId()) calls |toDo| for every node including
|
||||
|
|
Loading…
Add table
Reference in a new issue