forked from organicmaps/organicmaps
[routing] Incapsulated logic to delete temporary mwm indexes.
This commit is contained in:
parent
7a2430ab8f
commit
f8d3834f4c
3 changed files with 16 additions and 10 deletions
|
@ -355,7 +355,6 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
|
||||
if (newStatus == TStatus::EOnDisk)
|
||||
{
|
||||
m_framework.DeleteCountryIndexes(index);
|
||||
if (group != TGroup::EUpToDate)
|
||||
{
|
||||
// Here we handle
|
||||
|
|
|
@ -306,21 +306,23 @@ void Framework::DeleteCountry(TIndex const & index, TMapOptions opt)
|
|||
m_routingSession.DeleteIndexFile(file.GetFileWithExt(TMapOptions::ECarRouting));
|
||||
|
||||
m_storage.NotifyStatusChanged(index);
|
||||
}
|
||||
|
||||
DeleteCountryIndexes(index);
|
||||
DeleteCountryIndexes(m_storage.CountryFileNameWithoutExt(index));
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::DeleteCountryIndexes(TIndex const & index)
|
||||
void Framework::DeleteCountryIndexes(string const & mwmName)
|
||||
{
|
||||
string const & file = m_storage.CountryByIndex(index).Name();
|
||||
//Remove all indexes
|
||||
m_routingSession.Reset();
|
||||
|
||||
Platform::FilesList files;
|
||||
Platform const & pl = GetPlatform();
|
||||
pl.GetFilesByRegExp(pl.WritablePathForCountryIndexes(file), "*", files);
|
||||
string const path = pl.WritablePathForCountryIndexes(mwmName);
|
||||
|
||||
/// @todo We need correct regexp for any file (not including "." and "..").
|
||||
pl.GetFilesByRegExp(path, mwmName + "\\..*", files);
|
||||
for (auto const & file : files)
|
||||
my::DeleteFileX(file);
|
||||
(void) my::DeleteFileX(path + file);
|
||||
}
|
||||
|
||||
void Framework::DownloadCountry(TIndex const & index, TMapOptions opt)
|
||||
|
@ -391,6 +393,10 @@ void Framework::UpdateAfterDownload(string const & fileName, TMapOptions opt)
|
|||
routingName = GetPlatform().WritableDir() + routingName;
|
||||
VERIFY(my::RenameFileX(routingName + READY_FILE_EXTENSION, routingName), ());
|
||||
}
|
||||
|
||||
string countryName(fileName);
|
||||
my::GetNameWithoutExt(countryName);
|
||||
DeleteCountryIndexes(countryName);
|
||||
}
|
||||
|
||||
void Framework::AddMaps()
|
||||
|
|
|
@ -148,6 +148,9 @@ protected:
|
|||
|
||||
void RemoveMap(string const & file);
|
||||
|
||||
/// Deletes user calculated indexes on country updates
|
||||
void DeleteCountryIndexes(string const & mwmName);
|
||||
|
||||
public:
|
||||
Framework();
|
||||
virtual ~Framework();
|
||||
|
@ -170,8 +173,6 @@ public:
|
|||
void DeleteCountry(storage::TIndex const & index, storage::TMapOptions opt);
|
||||
/// options - flags that signal about parts of map that must be downloaded
|
||||
void DownloadCountry(storage::TIndex const & index, storage::TMapOptions opt);
|
||||
/// Deletes user calculated indexes on country updates
|
||||
void DeleteCountryIndexes(storage::TIndex const & index);
|
||||
|
||||
storage::TStatus GetCountryStatus(storage::TIndex const & index) const;
|
||||
string GetCountryName(storage::TIndex const & index) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue