forked from organicmaps/organicmaps
[storage] got rid m_localMapsInfo member from diff manager
This commit is contained in:
parent
0adbd86f85
commit
0dbc21adc4
3 changed files with 21 additions and 21 deletions
|
@ -27,10 +27,7 @@ namespace diffs
|
|||
{
|
||||
void Manager::Load(LocalMapsInfo && info)
|
||||
{
|
||||
LocalMapsInfo localMapsInfo = info;
|
||||
m_localMapsInfo = std::move(info);
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::Network, [this, info = std::move(localMapsInfo)] {
|
||||
GetPlatform().RunTask(Platform::Thread::Network, [this, info = std::move(info)] {
|
||||
NameDiffInfoMap diffs = Checker::Check(info);
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, diffs = std::move(diffs)] {
|
||||
|
@ -181,19 +178,5 @@ void Manager::AbortDiffScheme()
|
|||
m_status = Status::NotAvailable;
|
||||
m_diffs.clear();
|
||||
}
|
||||
|
||||
bool Manager::IsPossibleToAutoupdate() const
|
||||
{
|
||||
if (m_status != Status::Available)
|
||||
return false;
|
||||
|
||||
for (auto const & nameVersion : m_localMapsInfo.m_localMaps)
|
||||
{
|
||||
auto const it = m_diffs.find(nameVersion.first);
|
||||
if (it == m_diffs.cend() || it->second.m_isApplied)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace diffs
|
||||
} // namespace storage
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
bool SizeToDownloadFor(storage::CountryId const & countryId, uint64_t & size) const;
|
||||
|
||||
bool VersionFor(storage::CountryId const & countryId, uint64_t & version) const;
|
||||
bool IsPossibleToAutoupdate() const;
|
||||
|
||||
// Checks whether the diff for |countryId| is available for download or
|
||||
// has been downloaded.
|
||||
|
@ -90,7 +89,6 @@ private:
|
|||
|
||||
Status m_status = Status::Undefined;
|
||||
NameDiffInfoMap m_diffs;
|
||||
LocalMapsInfo m_localMapsInfo;
|
||||
base::ObserverListUnsafe<Observer> m_observers;
|
||||
};
|
||||
} // namespace diffs
|
||||
|
|
|
@ -1617,7 +1617,26 @@ void Storage::ApplyDiff(CountryId const & countryId, function<void(bool isSucces
|
|||
bool Storage::IsPossibleToAutoupdate() const
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
return m_diffManager.IsPossibleToAutoupdate();
|
||||
if (m_diffManager.GetStatus() != diffs::Status::Available)
|
||||
return false;
|
||||
|
||||
bool isPossibleToAutoupdate = true;
|
||||
auto const currentVersion = GetCurrentDataVersion();
|
||||
CountriesVec localMaps;
|
||||
GetLocalRealMaps(localMaps);
|
||||
for (auto const & countryId : localMaps)
|
||||
{
|
||||
auto const localFile = GetLatestLocalFile(countryId);
|
||||
auto const mapVersion = localFile->GetVersion();
|
||||
if (mapVersion != currentVersion && mapVersion > 0 &&
|
||||
!m_diffManager.HasDiffFor(localFile->GetCountryName()))
|
||||
{
|
||||
isPossibleToAutoupdate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isPossibleToAutoupdate;
|
||||
}
|
||||
|
||||
void Storage::SetStartDownloadingCallback(StartDownloadingCallback const & cb)
|
||||
|
|
Loading…
Add table
Reference in a new issue