mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[android] Use separate function to check for MapTooOldToEdit
Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -1252,16 +1252,33 @@ bool Storage::IsAllowedToEditVersion(CountryId const & countryId) const
|
||||
case Status::OnDiskOutOfDate:
|
||||
{
|
||||
auto const localFile = GetLatestLocalFile(countryId);
|
||||
ASSERT(localFile, ("Local file shouldn't be nullptr."));
|
||||
auto const currentVersionTime = base::YYMMDDToSecondsSinceEpoch(static_cast<uint32_t>(m_currentVersion));
|
||||
auto const localVersionTime = base::YYMMDDToSecondsSinceEpoch(static_cast<uint32_t>(localFile->GetVersion()));
|
||||
return currentVersionTime - localVersionTime < kMaxSecondsTillLastVersionUpdate &&
|
||||
base::SecondsSinceEpoch() - localVersionTime < kMaxSecondsTillNoEdits;
|
||||
return IsAllowedToEditFile(localFile);
|
||||
}
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Storage::IsMapTooOldToEdit(CountryId const & countryId) const
|
||||
{
|
||||
auto const status = CountryStatusEx(countryId);
|
||||
if (status == Status::OnDiskOutOfDate)
|
||||
{
|
||||
LocalFilePtr const localFile = GetLatestLocalFile(countryId);
|
||||
return !IsAllowedToEditFile(localFile);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::IsAllowedToEditFile(LocalFilePtr const & localFile) const
|
||||
{
|
||||
ASSERT(localFile, ("Local file shouldn't be nullptr."));
|
||||
auto const currentVersionTime = base::YYMMDDToSecondsSinceEpoch(static_cast<uint32_t>(m_currentVersion));
|
||||
auto const localVersionTime = base::YYMMDDToSecondsSinceEpoch(static_cast<uint32_t>(localFile->GetVersion()));
|
||||
return currentVersionTime - localVersionTime < kMaxSecondsTillLastVersionUpdate &&
|
||||
base::SecondsSinceEpoch() - localVersionTime < kMaxSecondsTillNoEdits;
|
||||
}
|
||||
|
||||
int64_t Storage::GetVersion(CountryId const & countryId) const
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
||||
@@ -383,6 +383,9 @@ public:
|
||||
/// \brief Returns true if the version of countryId can be used to update maps.
|
||||
bool IsAllowedToEditVersion(CountryId const & countryId) const;
|
||||
|
||||
/// \brief Returns true when the map exists and is too old for map editing.
|
||||
bool IsMapTooOldToEdit(CountryId const & countryId) const;
|
||||
|
||||
/// Returns version of downloaded mwm or zero.
|
||||
int64_t GetVersion(CountryId const & countryId) const;
|
||||
|
||||
@@ -619,6 +622,8 @@ private:
|
||||
// Returns a path to a place on disk downloader can use for downloaded files.
|
||||
std::string GetFileDownloadPath(CountryId const & countryId, MapFileType file) const;
|
||||
|
||||
bool IsAllowedToEditFile(LocalFilePtr const & localFile) const;
|
||||
|
||||
/// Fast version, doesn't check if country is out of date
|
||||
Status CountryStatus(CountryId const & countryId) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user