| 302 | } |
| 303 | |
| 304 | void Storage::RunCountriesCheckAsyncSaveOnly() |
| 305 | { |
| 306 | std::string const serverMapsUrl = "meta/" SERVER_MAPS_FILE; |
| 307 | LOG(LINFO, ("COUNTRIES: check for map updates by fetching", serverMapsUrl)); |
| 308 | |
| 309 | m_downloader->DownloadAsStringFromMeta(serverMapsUrl, [this, serverMapsUrl](std::string const & mapsBuffer) |
| 310 | { |
| 311 | if (mapsBuffer.empty()) |
| 312 | { |
| 313 | LOG(LWARNING, ("COUNTRIES:", serverMapsUrl, "empty response or error - skip update")); |
| 314 | NotifyCheckUpdatesResult(storage::CheckUpdatesStatus::Error); |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | LOG(LDEBUG, ("COUNTRIES: parsing downloaded", serverMapsUrl)); |
| 319 | bool isEOL = false; |
| 320 | int64_t const dataVersion = ParseServerMapsAndGetLatestVersion(mapsBuffer, isEOL); |
| 321 | if (dataVersion == 0) |
| 322 | { |
| 323 | LOG(LWARNING, ("COUNTRIES: latest map version info not found for map series", MAP_SERIES)); |
| 324 | NotifyCheckUpdatesResult(storage::CheckUpdatesStatus::Error); |
| 325 | return false; |
| 326 | } |
| 327 | LOG(LINFO, ("COUNTRIES:", dataVersion, "is latest map version for series", MAP_SERIES, "isEOL:", isEOL)); |
| 328 | if (dataVersion <= m_currentVersion) |
| 329 | { |
| 330 | LOG(LDEBUG, ("COUNTRIES:", dataVersion, "is not newer than current", m_currentVersion, "- skipping")); |
| 331 | if (isEOL) |
| 332 | NotifyCheckUpdatesResult(storage::CheckUpdatesStatus::EOL); |
| 333 | else |
| 334 | NotifyCheckUpdatesResult(storage::CheckUpdatesStatus::NoUpdate); |
| 335 | return false; |
| 336 | } |
| 337 | |
| 338 | /// @todo(pastk): request servers list from meta using the new/pending data version. |
| 339 | /// e.g. temporary set m_downloader->SetDataVersion(dataVersion); or pass new version as a param. |
| 340 | // Force fetch new servers list for new data version. |
| 341 | m_downloader->ResetMetaConfig(); |
| 342 | |
| 343 | auto const countriesUrl = downloader::GetFileDownloadUrl(COUNTRIES_FILE, dataVersion); |
| 344 | LOG(LINFO, ("COUNTRIES: fetching updated", dataVersion, "maps list from", countriesUrl)); |
| 345 | // Use MapFilesDownloader so we respect custom server / metaserver selection. |
| 346 | m_downloader->DownloadAsString(countriesUrl, [this, dataVersion](std::string const & buffer) |
| 347 | { |
| 348 | LOG(LDEBUG, ("COUNTRIES: downloaded bytes=", buffer.size())); |
| 349 | |
| 350 | if (buffer.empty()) |
| 351 | { |
| 352 | LOG(LWARNING, ("COUNTRIES:", COUNTRIES_FILE, "empty response or error - skip update")); |
| 353 | NotifyCheckUpdatesResult(storage::CheckUpdatesStatus::Error); |
| 354 | return false; |
| 355 | } |
| 356 | |
| 357 | CountryTree countries; |
| 358 | Affiliations affiliations; |
| 359 | CountryNameSynonyms synonyms; |
| 360 | MwmTopCityGeoIds topCities; |
| 361 | MwmTopCountryGeoIds topCountries; |
no test coverage detected