[new downloader] Correct restore downloading queue

This commit is contained in:
Sergey Yershov 2016-02-03 18:59:57 +03:00
parent 2a6fe823e2
commit 1d33afd38f

View file

@ -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<TLocalFilePtr> & maps) const