| 821 | } |
| 822 | |
| 823 | void Storage::DownloadCountry(CountryId const & countryId, MapFileType type) |
| 824 | { |
| 825 | CHECK_THREAD_CHECKER(m_threadChecker, ()); |
| 826 | |
| 827 | if (IsCountryInQueue(countryId) || IsDiffApplyingInProgressToCountry(countryId)) |
| 828 | return; |
| 829 | |
| 830 | m_failedCountries.erase(countryId); |
| 831 | auto const countryFile = GetCountryFile(countryId); |
| 832 | // If it's not even possible to prepare directory for files before |
| 833 | // downloading, then mark this country as failed and switch to next |
| 834 | // country. |
| 835 | if (!PreparePlaceForCountryFiles(m_currentVersion, m_dataDir, countryFile)) |
| 836 | { |
| 837 | OnMapDownloadFinished(countryId, DownloadStatus::Failed, type); |
| 838 | return; |
| 839 | } |
| 840 | |
| 841 | if (IsFileDownloaded(GetFileDownloadPath(countryId, type), type)) |
| 842 | { |
| 843 | OnMapDownloadFinished(countryId, DownloadStatus::Completed, type); |
| 844 | return; |
| 845 | } |
| 846 | |
| 847 | QueuedCountry queuedCountry(countryFile, countryId, type, m_currentVersion, m_dataDir, m_diffsDataSource); |
| 848 | queuedCountry.Subscribe(*this); |
| 849 | |
| 850 | m_downloader->DownloadMapFile(std::move(queuedCountry)); |
| 851 | } |
| 852 | |
| 853 | void Storage::DeleteCountry(CountryId const & countryId, MapFileType type) |
| 854 | { |