diff --git a/coding/coding_tests/files_container_tests.cpp b/coding/coding_tests/files_container_tests.cpp index 6b49eea188..3d694605c0 100644 --- a/coding/coding_tests/files_container_tests.cpp +++ b/coding/coding_tests/files_container_tests.cpp @@ -217,6 +217,48 @@ UNIT_TEST(FilesContainer_RewriteExisting) FileWriter::DeleteFileX(fName); } +/// @todo To make this test work, need to review FilesContainerW::GetWriter logic. +/* +UNIT_TEST(FilesContainer_ConsecutiveRewriteExisting) +{ + string const fName = "files_container.tmp"; + FileWriter::DeleteFileX(fName); + + char const * key[] = { "3", "2", "1" }; + char const * value[] = { "prolog", "data", "epilog" }; + + // fill container + { + FilesContainerW writer(fName); + + for (size_t i = 0; i < ARRAY_SIZE(key); ++i) + { + auto w = writer.GetWriter(key[i]); + w->Write(value[i], strlen(value[i])); + } + } + + char const * buf0 = "xxx"; + char const * buf1 = "yyy"; + { + FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING); + + { + auto w = writer.GetWriter(key[0]); + w->Write(buf0, strlen(buf0)); + } + + { + auto w = writer.GetWriter(key[1]); + w->Write(buf1, strlen(buf1)); + } + } + + char const * values[] = { buf0, buf1, value[2] }; + CheckContainer(fName, key, values, 3); +} +*/ + UNIT_TEST(FilesMappingContainer_Handle) { string const fName = "files_container.tmp"; diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index eef9f64292..9e270fa0b0 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -648,9 +648,14 @@ bool BuildSearchIndexFromDataFile(std::string const & country, feature::Generate writer->Seek(endOffset); } + /// @todo FilesContainerW::Write with section overriding invalidates current container instance + /// (@see FilesContainerW::GetWriter), thus we can't make 2 consecutive Write calls. { FilesContainerW writeContainer(readContainer.GetFileName(), FileWriter::OP_WRITE_EXISTING); writeContainer.Write(streetsFilePath, FEATURE2STREET_FILE_TAG); + } + { + FilesContainerW writeContainer(readContainer.GetFileName(), FileWriter::OP_WRITE_EXISTING); writeContainer.Write(placesFilePath, FEATURE2PLACE_FILE_TAG); } }