[generator] Fixed removing temporary files.

This commit is contained in:
Maksim Andrianov 2020-12-01 12:32:16 +03:00 committed by Tatiana Yan
parent c10dffc2f1
commit 81cbc6c1de
3 changed files with 13 additions and 4 deletions

View file

@ -60,7 +60,7 @@ class CollectorInterface
{
public:
CollectorInterface(std::string const & filename = {}) : m_id(CreateId()), m_filename(filename) {}
virtual ~CollectorInterface() { CHECK(Platform::RemoveFileIfExists(GetTmpFilename()), ()); }
virtual ~CollectorInterface() { CHECK(Platform::RemoveFileIfExists(GetTmpFilename()), (GetTmpFilename())); }
virtual std::shared_ptr<CollectorInterface> Clone(
std::shared_ptr<cache::IntermediateDataReaderInterface> const & = {}) const = 0;

View file

@ -274,6 +274,13 @@ RoutingCityBoundariesWriter::RoutingCityBoundariesWriter(std::string const & fil
{
}
RoutingCityBoundariesWriter::~RoutingCityBoundariesWriter()
{
CHECK(Platform::RemoveFileIfExists(m_nodeOsmIdToLocalityDataFilename), (m_nodeOsmIdToLocalityDataFilename));
CHECK(Platform::RemoveFileIfExists(m_nodeOsmIdToBoundariesFilename), (m_nodeOsmIdToBoundariesFilename));
CHECK(Platform::RemoveFileIfExists(m_finalBoundariesGeometryFilename), (m_finalBoundariesGeometryFilename));
}
void RoutingCityBoundariesWriter::Process(uint64_t nodeOsmId, LocalityData const & localityData)
{
m_nodeOsmIdToLocalityDataWriter->Write(&nodeOsmId, sizeof(nodeOsmId));
@ -306,17 +313,17 @@ void RoutingCityBoundariesWriter::Reset()
void RoutingCityBoundariesWriter::MergeInto(RoutingCityBoundariesWriter & writer)
{
CHECK(!m_nodeOsmIdToLocalityDataWriter || !writer.m_nodeOsmIdToLocalityDataWriter,
("Finish() has not been called."));
("Reset() has not been called."));
base::AppendFileToFile(m_nodeOsmIdToLocalityDataFilename,
writer.m_nodeOsmIdToLocalityDataFilename);
CHECK(!m_nodeOsmIdToBoundariesWriter || !writer.m_nodeOsmIdToBoundariesWriter,
("Finish() has not been called."));
("Reset() has not been called."));
base::AppendFileToFile(m_nodeOsmIdToBoundariesFilename,
writer.m_nodeOsmIdToBoundariesFilename);
CHECK(!m_finalBoundariesGeometryWriter || !writer.m_finalBoundariesGeometryWriter,
("Finish() has not been called."));
("Reset() has not been called."));
base::AppendFileToFile(m_finalBoundariesGeometryFilename,
writer.m_finalBoundariesGeometryFilename);
@ -335,6 +342,7 @@ void RoutingCityBoundariesWriter::Save(std::string const & finalFileName,
base::AppendFileToFile(m_nodeOsmIdToLocalityDataFilename, nodeToLocalityFilename);
base::AppendFileToFile(m_nodeOsmIdToBoundariesFilename, nodeToBoundariesFilename);
if (Platform::IsFileExistsByFullPath(m_finalBoundariesGeometryFilename))
CHECK(base::CopyFileX(m_finalBoundariesGeometryFilename, dumpFilename), ());
}

View file

@ -75,6 +75,7 @@ public:
static std::string GetBoundariesFilename(std::string const & filename);
explicit RoutingCityBoundariesWriter(std::string const & filename);
~RoutingCityBoundariesWriter();
void Process(uint64_t nodeOsmId, LocalityData const & localityData);
void Process(uint64_t nodeOsmId, feature::FeatureBuilder const & feature);