[android] Use separate function to check for MapTooOldToEdit

Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
map-per
2025-12-16 14:24:23 +01:00
committed by map-per
parent 3511dbb692
commit 8cffa508f3
5 changed files with 58 additions and 13 deletions

View File

@@ -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, ());