| 2111 | } |
| 2112 | |
| 2113 | bool Storage::GetUpdateInfo(CountryId const & countryId, UpdateInfo & updateInfo) const |
| 2114 | { |
| 2115 | CHECK_THREAD_CHECKER(m_threadChecker, ()); |
| 2116 | |
| 2117 | auto const updateInfoAccumulator = [&updateInfo, this](CountryTree::Node const & node) |
| 2118 | { |
| 2119 | if (node.ChildrenCount() != 0 || GetNodeStatus(node).status != NodeStatus::OnDiskOutOfDate) |
| 2120 | return; |
| 2121 | |
| 2122 | // Here the node is a leaf describing one mwm file (not a group node). |
| 2123 | |
| 2124 | CountryId const & countryId = node.Value().Name(); |
| 2125 | updateInfo.m_numberOfMwmFilesToUpdate += 1; |
| 2126 | |
| 2127 | LocalAndRemoteSize const sizes = CountrySizeInBytes(countryId); |
| 2128 | updateInfo.m_maxFileSizeInBytes = std::max(updateInfo.m_maxFileSizeInBytes, sizes.second); |
| 2129 | |
| 2130 | if (m_diffsDataSource->HasDiffFor(countryId)) |
| 2131 | { |
| 2132 | uint64_t size; |
| 2133 | m_diffsDataSource->SizeToDownloadFor(countryId, size); |
| 2134 | updateInfo.m_totalDownloadSizeInBytes += size; |
| 2135 | } |
| 2136 | else |
| 2137 | updateInfo.m_totalDownloadSizeInBytes += sizes.second; |
| 2138 | |
| 2139 | updateInfo.m_sizeDifference += static_cast<int64_t>(sizes.second) - static_cast<int64_t>(sizes.first); |
| 2140 | }; |
| 2141 | |
| 2142 | CountryTree::Node const * const node = m_countries.FindFirst(countryId); |
| 2143 | if (!node) |
| 2144 | { |
| 2145 | ASSERT(false, ()); |
| 2146 | return false; |
| 2147 | } |
| 2148 | updateInfo = {}; |
| 2149 | node->ForEachInSubtree(updateInfoAccumulator); |
| 2150 | return true; |
| 2151 | } |
| 2152 | |
| 2153 | /// @note No need to call CHECK_THREAD_CHECKER(m_threadChecker, ()) here and below, because |
| 2154 | /// we don't change all this containers during update. Consider checking, otherwise. |