[storage] Do delete old splitted map files (Brazil, Japan) when new regions are downloaded.

This commit is contained in:
vng 2014-10-09 19:58:00 +03:00 committed by Alex Zolotarev
parent 9fbe5893b0
commit da1eb2f4cf
2 changed files with 17 additions and 3 deletions

View file

@ -353,14 +353,27 @@ void Framework::ShowCountry(TIndex const & index)
void Framework::UpdateAfterDownload(string const & fileName, TMapOptions opt)
{
if (opt & TMapOptions::EMapOnly)
{
m2::RectD rect;
{
// Delete old (splitted) map files, if any.
char const * arr[] = { "Japan", "Brazil" };
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
if (fileName.find(arr[i]) == 0)
{
if (m_model.DeleteMap(string(arr[i]) + DATA_FILE_EXTENSION))
Invalidate(true);
// Routing index doesn't exist for this map files.
}
// Add downloaded map.
m2::RectD rect;
if (m_model.UpdateMap(fileName, rect))
InvalidateRect(rect, true);
InvalidateRect(rect, true);
GetSearchEngine()->ClearViewportsCache();
}
// Replace routing file.
if (opt & TMapOptions::ECarRouting)
{
string routingName = fileName + ROUTING_FILE_EXTENSION;

View file

@ -145,6 +145,7 @@ void RoutingSession::SetRouter(IRouter * router)
void RoutingSession::DeleteIndexFile(string const & fileName)
{
Reset();
m_router->ClearState();
(void) my::DeleteFileX(GetPlatform().WritablePathForFile(fileName));
}