diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 35b6d2b9e8..d176473a9b 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -123,7 +123,8 @@ pair MwmSet::RegisterImpl(LocalCountryFile // This function can throw an exception for a bad mwm file. if (!GetVersion(localFile, *info)) - return make_pair(MwmHandle(), RegResult::BadFile); + return make_pair(MwmHandle(), RegResult::UnsupportedFileFormat); + info->SetStatus(MwmInfo::STATUS_REGISTERED); info->m_file = localFile; string const name = localFile.GetCountryName(); @@ -315,5 +316,7 @@ string DebugPrint(MwmSet::RegResult result) return "VersionTooOld"; case MwmSet::RegResult::BadFile: return "BadFile"; + case MwmSet::RegResult::UnsupportedFileFormat: + return "UnsupportedFileFormat"; } } diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index b3e53d22c2..72ad83be95 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -162,6 +162,7 @@ public: Success, VersionAlreadyExists, VersionTooOld, + UnsupportedFileFormat, BadFile }; diff --git a/indexer/mwm_version.cpp b/indexer/mwm_version.cpp index e1c4f29792..7a641cee42 100644 --- a/indexer/mwm_version.cpp +++ b/indexer/mwm_version.cpp @@ -1,12 +1,10 @@ #include "indexer/mwm_version.hpp" -#include "indexer/data_header.hpp" #include "coding/file_container.hpp" #include "coding/reader_wrapper.hpp" #include "coding/varint.hpp" #include "coding/writer.hpp" -#include "base/logging.hpp" #include "base/timer.hpp" #include "defines.hpp" @@ -17,7 +15,6 @@ namespace version { namespace { -typedef feature::DataHeader FHeaderT; char const MWM_PROLOG[] = "MWM"; @@ -37,13 +34,9 @@ void ReadVersionT(TSource & src, MwmVersion & version) return; } - uint32_t formatIndex = ReadVarUint(src); - if (formatIndex > lastFormat) - { - LOG(LERROR, ("Unknown file format index:", formatIndex)); - formatIndex = lastFormat; - } - version.format = static_cast(formatIndex); + // Read format value "as-is". It's correctness will be checked later + // with the correspondent return value. + version.format = static_cast(ReadVarUint(src)); version.timestamp = ReadVarUint(src); } } // namespace @@ -68,6 +61,7 @@ bool ReadVersion(FilesContainerR const & container, MwmVersion & version) { if (!container.IsExist(VERSION_FILE_TAG)) return false; + ModelReaderPtr versionReader = container.GetReader(VERSION_FILE_TAG); ReaderSource src(versionReader); ReadVersionT(src, version);