[new downloader] Adding LocalCountryFile::SyncWithDisk() assumption that every single mwm has a routing sections.

This commit is contained in:
Vladimir Byko-Ianko 2016-02-03 13:03:24 +03:00 committed by Sergey Yershov
parent 5cc7c09e7f
commit f5d0c3b12e
3 changed files with 18 additions and 17 deletions

View file

@ -39,7 +39,11 @@ void LocalCountryFile::SyncWithDisk()
m_files = SetOptions(m_files, MapOptions::Map);
if (version::IsSingleMwm(GetVersion()))
{
if (m_files == MapOptions::Map)
m_files = SetOptions(m_files, MapOptions::CarRouting);
return;
}
string const routingPath = GetPath(MapOptions::CarRouting);
if (platform.GetFileSizeByFullPath(routingPath, m_routingSize))

View file

@ -35,6 +35,10 @@ public:
// Syncs internal state like availability of map and routing files,
// their sizes etc. with disk.
// In case of one component (single) mwm this method assumed the every mwm has a routing section.
// Generality speaking it's not always true. To know it for sure it's necessary to read a mwm in
// this method but it's not implemented by performance reasons. This check is done on
// building routes stage.
void SyncWithDisk();
// Removes specified files from disk if they're known for LocalCountryFile, i.e.

View file

@ -24,19 +24,14 @@ namespace
class LocalFileGenerator
{
public:
// Note. m_localFile has version == 0. That means it is considered as a two components mwm file
// with routing and map sections. It has mwm extention. So, to get correct path
// MapOptions::Map is used as a parameter of CountryFile::GetNameWithExt() method.
LocalFileGenerator(string const & fileName)
: m_countryFile(fileName),
m_testMapFile(platform::GetFileName(m_countryFile.GetName(), MapOptions::Map,
version::FOR_TESTING_TWO_COMPONENT_MWM1), "map"),
m_testRoutingFile(platform::GetFileName(m_countryFile.GetName(), MapOptions::CarRouting,
version::FOR_TESTING_TWO_COMPONENT_MWM1), "map"),
m_localFile(GetPlatform().WritableDir(), m_countryFile, 0 /* version */)
m_testDataFile(platform::GetFileName(m_countryFile.GetName(), MapOptions::MapWithCarRouting,
version::FOR_TESTING_SINGLE_MWM1), "routing"),
m_localFile(GetPlatform().WritableDir(), m_countryFile, version::FOR_TESTING_SINGLE_MWM1)
{
m_localFile.SyncWithDisk();
TEST(m_localFile.OnDisk(MapOptions::Map), ());
TEST(m_localFile.OnDisk(MapOptions::MapWithCarRouting), ());
GenerateNecessarySections(m_localFile);
m_result = m_testSet.Register(m_localFile);
@ -51,21 +46,19 @@ public:
size_t GetNumRefs() { return m_result.first.GetInfo()->GetNumRefs(); }
private:
void GenerateNecessarySections(LocalCountryFile const & localFile)
{
FilesContainerW routingCont(localFile.GetPath(MapOptions::CarRouting));
// Write version for routing file that is equal to correspondent mwm file.
FilesContainerW mwmCont(localFile.GetPath(MapOptions::Map));
FilesContainerW dataCont(localFile.GetPath(MapOptions::CarRouting));
FileWriter w1 = routingCont.GetWriter(VERSION_FILE_TAG);
FileWriter w2 = mwmCont.GetWriter(VERSION_FILE_TAG);
FileWriter w1 = dataCont.GetWriter(VERSION_FILE_TAG);
version::WriteVersion(w1, my::TodayAsYYMMDD());
version::WriteVersion(w2, my::TodayAsYYMMDD());
FileWriter w2 = dataCont.GetWriter(ROUTING_MATRIX_FILE_TAG);
w2.Write("smth", 4);
}
CountryFile m_countryFile;
ScopedFile m_testMapFile;
ScopedFile m_testRoutingFile;
ScopedFile m_testDataFile;
LocalCountryFile m_localFile;
TestMwmSet m_testSet;
pair<MwmSet::MwmId, MwmSet::RegResult> m_result;