From a64351d1e62ce58b5a4a8d768a8541c8771f294f Mon Sep 17 00:00:00 2001 From: Dmitry Yunitsky Date: Tue, 7 Jul 2015 18:54:27 +0300 Subject: [PATCH] Fixed download of non-mwm(eg .ttf) assets from servers. --- .../jni/com/mapswithme/maps/DownloadResourcesActivity.cpp | 6 +----- storage/storage.cpp | 8 ++++++-- storage/storage.hpp | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp index bd6993716b..4ef2534293 100644 --- a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp +++ b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp @@ -213,11 +213,7 @@ extern "C" storage::Storage const & storage = g_framework->Storage(); for (size_t i = 0; i < curFile.m_urls.size(); ++i) { - string baseName = curFile.m_fileName; - my::GetNameWithoutExt(baseName); - storage::TIndex const index = storage.FindIndexByFile(baseName); - - curFile.m_urls[i] = storage.GetFileDownloadUrl(curFile.m_urls[i], index, TMapOptions::EMap); + curFile.m_urls[i] = storage.GetFileDownloadUrl(curFile.m_urls[i], curFile.m_fileName); LOG(LDEBUG, (curFile.m_urls[i])); } diff --git a/storage/storage.cpp b/storage/storage.cpp index 21abc749b9..3072f6aafc 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -599,8 +599,12 @@ string Storage::GetFileDownloadUrl(string const & baseUrl, TIndex const & index, TMapOptions file) const { CountryFile const & countryFile = GetCountryFile(index); - return baseUrl + OMIM_OS_NAME "/" + strings::to_string(GetCurrentDataVersion()) + "/" + - UrlEncode(countryFile.GetNameWithExt(file)); + return GetFileDownloadUrl(baseUrl, countryFile.GetNameWithExt(file)); +} + +string Storage::GetFileDownloadUrl(string const & baseUrl, string const & fName) const +{ + return baseUrl + OMIM_OS_NAME "/" + strings::to_string(GetCurrentDataVersion()) + "/" + UrlEncode(fName); } TIndex Storage::FindIndexByFile(string const & name) const diff --git a/storage/storage.hpp b/storage/storage.hpp index b44839f1db..d025e631a6 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -162,7 +162,10 @@ public: void NotifyStatusChanged(TIndex const & index); + /// get download url by index & options(first search file name by index, then format url) string GetFileDownloadUrl(string const & baseUrl, TIndex const & index, TMapOptions file) const; + /// get download url by base url & file name + string GetFileDownloadUrl(string const & baseUrl, string const & fName) const; /// @param[out] res Populated with oudated countries. void GetOutdatedCountries(vector & countries) const;