Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-08-10 20:40:05 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:00:43 +0300
commitb95fc5602c66aaa060b6b40985ebbc71a7cc245a (patch)
tree3213cb4e6bc4c0724bf2ed0d66f46b737b601f0e
parent1b27253169d6a1fa61a61f3b638a0bc9c452440f (diff)
[storage] Fixed migrating bug with multiple Index for one mwm local country file.
-rw-r--r--map/active_maps_layout.cpp4
-rw-r--r--map/active_maps_layout.hpp10
-rw-r--r--map/country_tree.cpp2
-rw-r--r--map/country_tree.hpp7
-rw-r--r--map/framework.cpp10
-rw-r--r--storage/storage.cpp34
-rw-r--r--storage/storage.hpp2
7 files changed, 35 insertions, 34 deletions
diff --git a/map/active_maps_layout.cpp b/map/active_maps_layout.cpp
index 3755cc3b9d..5d735aacf6 100644
--- a/map/active_maps_layout.cpp
+++ b/map/active_maps_layout.cpp
@@ -36,14 +36,14 @@ ActiveMapsLayout::~ActiveMapsLayout()
#endif
}
-void ActiveMapsLayout::Init(vector<platform::CountryFile> const & files)
+void ActiveMapsLayout::Init(vector<TLocalFilePtr> const & files)
{
Clear();
Storage & storage = GetStorage();
for (auto const & file : files)
{
- vector<TIndex> arr = storage.FindAllIndexesByFile(file.GetNameWithoutExt());
+ vector<TIndex> arr = storage.FindAllIndexesByFile(file->GetCountryName());
if (!arr.empty())
{
TStatus status;
diff --git a/map/active_maps_layout.hpp b/map/active_maps_layout.hpp
index 81367527ae..5d62bbc2fe 100644
--- a/map/active_maps_layout.hpp
+++ b/map/active_maps_layout.hpp
@@ -4,14 +4,15 @@
#include "storage/storage_defines.hpp"
#include "platform/country_defines.hpp"
-#include "platform/country_file.hpp"
+#include "platform/local_country_file.hpp"
#include "base/buffer_vector.hpp"
+#include "std/function.hpp"
+#include "std/map.hpp"
+#include "std/shared_ptr.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
-#include "std/map.hpp"
-#include "std/function.hpp"
class Framework;
@@ -99,7 +100,8 @@ private:
Storage const & GetStorage() const;
Storage & GetStorage();
- void Init(vector<platform::CountryFile> const & files);
+ using TLocalFilePtr = shared_ptr<platform::LocalCountryFile>;
+ void Init(vector<TLocalFilePtr> const & files);
void Clear();
void ShowMap(TIndex const & index);
diff --git a/map/country_tree.cpp b/map/country_tree.cpp
index 0af4952864..2b3d3d81a0 100644
--- a/map/country_tree.cpp
+++ b/map/country_tree.cpp
@@ -65,7 +65,7 @@ CountryTree & CountryTree::operator=(CountryTree const & other)
return *this;
}
-void CountryTree::Init(vector<platform::CountryFile> const & maps)
+void CountryTree::Init(vector<ActiveMapsLayout::TLocalFilePtr> const & maps)
{
ASSERT(IsValid(), ());
m_layout->Init(maps);
diff --git a/map/country_tree.hpp b/map/country_tree.hpp
index 54d0259486..68f3d460f1 100644
--- a/map/country_tree.hpp
+++ b/map/country_tree.hpp
@@ -5,13 +5,14 @@
#include "storage/index.hpp"
#include "storage/storage_defines.hpp"
-#include "platform/country_file.hpp"
+#include "platform/local_country_file.hpp"
#include "base/buffer_vector.hpp"
-#include "std/string.hpp"
#include "std/function.hpp"
#include "std/shared_ptr.hpp"
+#include "std/string.hpp"
+
class Framework;
@@ -38,7 +39,7 @@ public:
CountryTree & operator=(CountryTree const & other);
/// @param[in] Sorted vector of current .mwm files.
- void Init(vector<platform::CountryFile> const & maps);
+ void Init(vector<ActiveMapsLayout::TLocalFilePtr> const & maps);
void Clear();
ActiveMapsLayout & GetActiveMapLayout();
diff --git a/map/framework.cpp b/map/framework.cpp
index ef8296b018..a3f655c432 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -473,15 +473,11 @@ void Framework::RegisterAllMaps()
m_storage.RegisterAllLocalMaps();
int minFormat = numeric_limits<int>::max();
- vector<CountryFile> maps;
- m_storage.GetLocalMaps(maps);
- for (CountryFile const & countryFile : maps)
+ vector<shared_ptr<LocalCountryFile>> maps;
+ m_storage.GetLocalMaps(maps);
+ for (auto const & localFile : maps)
{
- shared_ptr<LocalCountryFile> localFile = m_storage.GetLatestLocalFile(countryFile);
- if (!localFile)
- continue;
-
auto p = RegisterMap(*localFile);
if (p.second != MwmSet::RegResult::Success)
continue;
diff --git a/storage/storage.cpp b/storage/storage.cpp
index 22a4272c82..9e0f3309ce 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -149,15 +149,15 @@ void Storage::RegisterAllLocalMaps()
}
}
-void Storage::GetLocalMaps(vector<CountryFile> & maps) const
+void Storage::GetLocalMaps(vector<TLocalFilePtr> & maps) const
{
for (auto const & p : m_localFiles)
- {
- TIndex const & index = p.first;
- maps.push_back(GetLatestLocalFile(index)->GetCountryFile());
- }
+ maps.push_back(GetLatestLocalFile(p.first));
+
for (auto const & p : m_localFilesForFakeCountries)
- maps.push_back(p.second->GetCountryFile());
+ maps.push_back(p.second);
+
+ maps.erase(unique(maps.begin(), maps.end()), maps.end());
}
size_t Storage::GetDownloadedFilesCount() const
@@ -331,7 +331,7 @@ void Storage::DeleteCountry(TIndex const & index, MapOptions opt)
DeleteCountryFiles(index, opt);
DeleteCountryFilesFromDownloader(index, opt);
- auto localFile = GetLatestLocalFile(index);
+ TLocalFilePtr localFile = GetLatestLocalFile(index);
if (localFile)
m_update(*localFile);
@@ -675,7 +675,7 @@ void Storage::GetOutdatedCountries(vector<Country const *> & countries) const
{
TIndex const & index = p.first;
string const name = GetCountryFile(index).GetNameWithoutExt();
- TLocalFilePtr const & file = GetLatestLocalFile(index);
+ TLocalFilePtr file = GetLatestLocalFile(index);
if (file && file->GetVersion() != GetCurrentDataVersion() &&
name != WORLD_COASTS_FILE_NAME && name != WORLD_FILE_NAME)
{
@@ -769,8 +769,8 @@ Storage::TLocalFilePtr Storage::GetLocalFile(TIndex const & index, int64_t versi
auto const it = m_localFiles.find(index);
if (it == m_localFiles.end() || it->second.empty())
return TLocalFilePtr();
- list<TLocalFilePtr> const & files = it->second;
- for (TLocalFilePtr const & file : files)
+
+ for (auto const & file : it->second)
{
if (file->GetVersion() == version)
return file;
@@ -783,12 +783,14 @@ void Storage::RegisterCountryFiles(TLocalFilePtr localFile)
CHECK(localFile, ());
localFile->SyncWithDisk();
- TIndex const index = FindIndexByFile(localFile->GetCountryName());
- TLocalFilePtr existingFile = GetLocalFile(index, localFile->GetVersion());
- if (existingFile)
- ASSERT_EQUAL(localFile.get(), existingFile.get(), ());
- else
- m_localFiles[index].push_front(localFile);
+ for (auto const & index : FindAllIndexesByFile(localFile->GetCountryName()))
+ {
+ TLocalFilePtr existingFile = GetLocalFile(index, localFile->GetVersion());
+ if (existingFile)
+ ASSERT_EQUAL(localFile.get(), existingFile.get(), ());
+ else
+ m_localFiles[index].push_front(localFile);
+ }
}
void Storage::RegisterCountryFiles(TIndex const & index, string const & directory, int64_t version)
diff --git a/storage/storage.hpp b/storage/storage.hpp
index 8a448779c1..2d3b69eb32 100644
--- a/storage/storage.hpp
+++ b/storage/storage.hpp
@@ -116,7 +116,7 @@ public:
void RegisterAllLocalMaps();
// Returns list of all local maps, including fake countries (World*.mwm).
- void GetLocalMaps(vector<platform::CountryFile> & maps) const;
+ void GetLocalMaps(vector<TLocalFilePtr> & maps) const;
// Returns number of downloaded maps (files), excluding fake countries (World*.mwm).
size_t GetDownloadedFilesCount() const;