From 1d33afd38f4aaf3b6f99b96d6159e50e8deb0800 Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Wed, 3 Feb 2016 18:59:57 +0300 Subject: [PATCH] [new downloader] Correct restore downloading queue --- storage/storage.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/storage/storage.cpp b/storage/storage.cpp index 5f69e2aab8..4b65959552 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -88,13 +88,7 @@ Storage::Storage(string const & pathToCountriesFile /* = COUNTRIES_FILE */, stri : m_downloader(new HttpMapFilesDownloader()), m_currentSlotId(0), m_dataDir(dataDir), m_downloadMapOnTheMap(nullptr) { - - LoadCountriesFile(pathToCountriesFile, m_dataDir); - - // WARNING! RestoreDownloadQueue should be called after RegisterAllLocalMaps - // otherwise RegisterAllLocalMaps breaks downloading queue. - // RestoreDownloadQueue(); } Storage::Storage(string const & referenceCountriesTxtJsonForTesting, @@ -160,15 +154,15 @@ void Storage::Migrate(TCountriesVec const & existedCountries) my::RenameFileX(prefetchedFilename, localFilename); } - // Cover old big maps with small ones and add them into download queue + // Cover old big maps with small ones and prepare them to add into download queue + stringstream ss; for (auto const & country : existedCountries) { ASSERT(!mapping[country].empty(), ()); for (auto const & smallCountry : mapping[country]) - { - DownloadCountry(smallCountry, MapOptions::Map); - } + ss << (ss.str().empty() ? "" : ";") << smallCountry; } + Settings::Set("DownloadQueue", ss.str()); } void Storage::Clear() @@ -228,6 +222,7 @@ void Storage::RegisterAllLocalMaps() i = j; } + RestoreDownloadQueue(); } void Storage::GetLocalMaps(vector & maps) const