From 3d4953ee794075b079a1a71d7cd6c3eb6248aea1 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Mon, 4 Apr 2016 12:04:12 +0300 Subject: [PATCH] Review fixes. --- iphone/Maps/Classes/Storage/MWMStorage.mm | 4 +--- map/framework.cpp | 3 +-- storage/storage_helpers.cpp | 9 ++++----- storage/storage_helpers.hpp | 2 ++ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/iphone/Maps/Classes/Storage/MWMStorage.mm b/iphone/Maps/Classes/Storage/MWMStorage.mm index bcefe4f0da..c577fe4547 100644 --- a/iphone/Maps/Classes/Storage/MWMStorage.mm +++ b/iphone/Maps/Classes/Storage/MWMStorage.mm @@ -75,15 +75,13 @@ using namespace storage; alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess { - size_t requiredSize = accumulate(countryIds.begin(), countryIds.end(), 0, + size_t requiredSize = accumulate(countryIds.begin(), countryIds.end(), kMaxMwmSizeBytes, [](size_t const & size, TCountryId const & countryId) { NodeAttrs nodeAttrs; GetFramework().Storage().GetNodeAttrs(countryId, nodeAttrs); return size + nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; }); - size_t constexpr kDownloadExtraSpaceSize = 100 * MB; - requiredSize += kDownloadExtraSpaceSize; if (GetPlatform().GetWritableStorageStatus(requiredSize) == Platform::TStorageStatus::STORAGE_OK) { [self checkConnectionAndPerformAction:[countryIds, onSuccess] diff --git a/map/framework.cpp b/map/framework.cpp index ed7d0e6964..86d1f48f83 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -240,8 +240,7 @@ void Framework::StopLocationFollow() bool Framework::IsEnoughSpaceForMigrate() const { - uint64_t const kSpaceSize = 100 /*Mb*/ * 1024 * 1024; - return GetPlatform().GetWritableStorageStatus(kSpaceSize) == Platform::TStorageStatus::STORAGE_OK; + return GetPlatform().GetWritableStorageStatus(kMaxMwmSizeBytes) == Platform::TStorageStatus::STORAGE_OK; } TCountryId Framework::PreMigrate(ms::LatLon const & position, diff --git a/storage/storage_helpers.cpp b/storage/storage_helpers.cpp index 4cae2c2566..4c632c5f35 100644 --- a/storage/storage_helpers.cpp +++ b/storage/storage_helpers.cpp @@ -24,12 +24,11 @@ bool IsEnoughSpaceForDownload(TCountryId const & countryId, Storage const & stor { NodeAttrs nodeAttrs; storage.GetNodeAttrs(countryId, nodeAttrs); - // Mwm size is less than 100 MB. In case of map update at first we download updated map and only - // after that we do delete the obsolete map. So in such a case we might need up to 100 MB of extra - // space. - size_t constexpr kDownloadExtraSpaceSize = 100 /*Mb*/ * 1024 * 1024; + // Mwm size is less than kMaxMwmSizeBytes. In case of map update at first we download updated map + // and only after that we do delete the obsolete map. So in such a case we might need up to + // kMaxMwmSizeBytes of extra space. size_t const downloadSpaceSize = - kDownloadExtraSpaceSize + nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; + kMaxMwmSizeBytes + nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; return GetPlatform().GetWritableStorageStatus(downloadSpaceSize) == Platform::TStorageStatus::STORAGE_OK; } diff --git a/storage/storage_helpers.hpp b/storage/storage_helpers.hpp index c2db12d787..c849be21c2 100644 --- a/storage/storage_helpers.hpp +++ b/storage/storage_helpers.hpp @@ -11,6 +11,8 @@ namespace storage class CountryInfoGetter; class Storage; +size_t constexpr kMaxMwmSizeBytes = 100 /*Mb*/ * 1024 * 1024; + /// \returns true if |position| is covered by a downloaded mwms and false otherwise. /// \note |position| has coordinates in mercator. /// \note This method takes into acount only maps enumerated in countries.txt.