[local_ads] Truncate the old file when writing metadata.

This commit is contained in:
Maxim Pimenov 2020-03-04 17:54:15 +03:00 committed by Arsentiy Milchakov
parent b438341357
commit b22d32d124

View file

@ -314,7 +314,11 @@ std::list<Event> Statistics::WriteEvents(std::list<Event> & events, std::string
}
if (writer == nullptr || writer->GetName() != metadata.m_fileName)
writer = std::make_unique<FileWriter>(metadata.m_fileName, FileWriter::OP_APPEND);
{
writer = std::make_unique<FileWriter>(
metadata.m_fileName,
needWriteMetadata ? FileWriter::OP_WRITE_TRUNCATE : FileWriter::OP_APPEND);
}
if (needWriteMetadata)
WriteMetadata(*writer, event.m_countryId, event.m_mwmVersion, metadata.m_timestamp);