diff options
author | Dmitry Yunitsky <dmitry.yunitsky@gmail.com> | 2016-04-12 20:39:54 +0300 |
---|---|---|
committer | Dmitry Yunitsky <dmitry.yunitsky@gmail.com> | 2016-04-12 20:39:54 +0300 |
commit | de9f48aaa8c3cf201a96b54761d0a6413078364d (patch) | |
tree | 9fe1c7581bfb8429937a226dfca4b3761050ccd2 /storage | |
parent | ad4d681fa5514a9e16d84a3b889491d19d36ea2b (diff) | |
parent | bbfd7443c4f47174cf76febce8f136436a1d82b9 (diff) |
Merge pull request #2868 from trashkalmar/notify-no-space-on-download
[new downloader][android] fix: Check free space before downloading maps.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/storage_helpers.cpp | 15 | ||||
-rw-r--r-- | storage/storage_helpers.hpp | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/storage/storage_helpers.cpp b/storage/storage_helpers.cpp index 4c632c5f35..48cc8e723c 100644 --- a/storage/storage_helpers.cpp +++ b/storage/storage_helpers.cpp @@ -20,19 +20,22 @@ bool IsDownloadFailed(Status status) status == Status::EUnknown; } -bool IsEnoughSpaceForDownload(TCountryId const & countryId, Storage const & storage) +bool IsEnoughSpaceForDownload(TMwmSize size) { - NodeAttrs nodeAttrs; - storage.GetNodeAttrs(countryId, nodeAttrs); // 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 = - kMaxMwmSizeBytes + nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; - return GetPlatform().GetWritableStorageStatus(downloadSpaceSize) == + return GetPlatform().GetWritableStorageStatus(size + kMaxMwmSizeBytes) == Platform::TStorageStatus::STORAGE_OK; } +bool IsEnoughSpaceForDownload(TCountryId const & countryId, Storage const & storage) +{ + NodeAttrs nodeAttrs; + storage.GetNodeAttrs(countryId, nodeAttrs); + return IsEnoughSpaceForDownload(nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize); +} + m2::RectD CalcLimitRect(TCountryId const & countryId, Storage const & storage, CountryInfoGetter const & countryInfoGetter) diff --git a/storage/storage_helpers.hpp b/storage/storage_helpers.hpp index c849be21c2..37e8ac33d1 100644 --- a/storage/storage_helpers.hpp +++ b/storage/storage_helpers.hpp @@ -11,7 +11,7 @@ namespace storage class CountryInfoGetter; class Storage; -size_t constexpr kMaxMwmSizeBytes = 100 /*Mb*/ * 1024 * 1024; +TMwmSize 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. @@ -22,6 +22,7 @@ bool IsPointCoveredByDownloadedMaps(m2::PointD const & position, bool IsDownloadFailed(Status status); +bool IsEnoughSpaceForDownload(TMwmSize size); bool IsEnoughSpaceForDownload(TCountryId const & countryId, Storage const & storage); /// \brief Calculates limit rect for |countryId| (expandable or not). |