forked from organicmaps/organicmaps
[storage] review fixes
This commit is contained in:
parent
d640f892bd
commit
83bae35a7e
4 changed files with 20 additions and 22 deletions
|
@ -39,12 +39,13 @@ void Manager::Load(NameDiffInfoMap && info)
|
|||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void Manager::ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancellable,
|
||||
Manager::OnDiffApplicationFinished const & task)
|
||||
{
|
||||
using namespace generator::mwm_diff;
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::File, [this, p = std::move(p), &cancellable, task] {
|
||||
GetPlatform().RunTask(Platform::Thread::File, [p = std::move(p), &cancellable, task] {
|
||||
CHECK(p.m_diffFile, ());
|
||||
CHECK(p.m_oldMwmFile, ());
|
||||
|
||||
|
@ -101,11 +102,8 @@ void Manager::ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancella
|
|||
break;
|
||||
}
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, task, result]()
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [task, result]()
|
||||
{
|
||||
if (result == DiffApplicationResult::Failed)
|
||||
m_status = Status::NotAvailable;
|
||||
|
||||
task(result);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -59,8 +59,9 @@ public:
|
|||
Status GetStatus() const;
|
||||
|
||||
void Load(NameDiffInfoMap && info);
|
||||
void ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancellable,
|
||||
OnDiffApplicationFinished const & task);
|
||||
static void ApplyDiff(ApplyDiffParams && p, base::Cancellable const & cancellable,
|
||||
OnDiffApplicationFinished const & task);
|
||||
|
||||
private:
|
||||
template <typename Fn>
|
||||
bool WithNotAppliedDiff(storage::CountryId const & countryId, Fn && fn) const
|
||||
|
|
|
@ -138,14 +138,15 @@ namespace storage
|
|||
{
|
||||
namespace diffs
|
||||
{
|
||||
//static
|
||||
// static
|
||||
void Loader::Load(LocalMapsInfo && info, DiffsReceivedCallback && callback)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Network, [info = move(info), callback = move(callback)]() {
|
||||
GetPlatform().RunTask(Platform::Thread::Gui,
|
||||
[result = ::Load(info), callback = move(callback)]() mutable {
|
||||
callback(move(result));
|
||||
});
|
||||
GetPlatform().RunTask(Platform::Thread::Network, [info = move(info), callback = move(callback)]() {
|
||||
auto result = ::Load(info);
|
||||
GetPlatform().RunTask(Platform::Thread::Gui,
|
||||
[result = move(result), callback = move(callback)]() mutable {
|
||||
callback(move(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
} // namespace diffs
|
||||
|
|
|
@ -330,8 +330,8 @@ void Storage::RegisterAllLocalMaps(bool enableDiffs)
|
|||
if (enableDiffs)
|
||||
LoadDiffScheme();
|
||||
// Note: call order is important, diffs loading must be called first.
|
||||
// Because of diffs downloading and servers list downloading
|
||||
// are working on network thread, consequtive executing is guaranteed.
|
||||
// Since diffs downloading and servers list downloading
|
||||
// are working on network thread, consecutive executing is guaranteed.
|
||||
RestoreDownloadQueue();
|
||||
}
|
||||
|
||||
|
@ -483,11 +483,11 @@ Status Storage::CountryStatusEx(CountryId const & countryId) const
|
|||
if (status != Status::EUnknown)
|
||||
return status;
|
||||
|
||||
LocalFilePtr localFile = GetLatestLocalFile(countryId);
|
||||
auto localFile = GetLatestLocalFile(countryId);
|
||||
if (!localFile || !localFile->OnDisk(MapOptions::Map))
|
||||
return Status::ENotDownloaded;
|
||||
|
||||
CountryFile const & countryFile = GetCountryFile(countryId);
|
||||
auto const & countryFile = GetCountryFile(countryId);
|
||||
if (GetRemoteSize(countryFile, MapOptions::Map, GetCurrentDataVersion()) == 0)
|
||||
return Status::EUnknown;
|
||||
|
||||
|
@ -1561,7 +1561,7 @@ void Storage::ApplyDiff(CountryId const & countryId, function<void(bool isSucces
|
|||
|
||||
LocalFilePtr & diffFile = params.m_diffFile;
|
||||
|
||||
m_diffManager.ApplyDiff(
|
||||
diffs::Manager::ApplyDiff(
|
||||
move(params), m_diffsCancellable,
|
||||
[this, fn, countryId, diffFile](DiffApplicationResult result) {
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
@ -1614,7 +1614,6 @@ bool Storage::IsPossibleToAutoupdate() const
|
|||
if (m_diffManager.GetStatus() != diffs::Status::Available)
|
||||
return false;
|
||||
|
||||
bool isPossibleToAutoupdate = true;
|
||||
auto const currentVersion = GetCurrentDataVersion();
|
||||
CountriesVec localMaps;
|
||||
GetLocalRealMaps(localMaps);
|
||||
|
@ -1625,12 +1624,11 @@ bool Storage::IsPossibleToAutoupdate() const
|
|||
if (mapVersion != currentVersion && mapVersion > 0 &&
|
||||
!m_diffManager.HasDiffFor(localFile->GetCountryName()))
|
||||
{
|
||||
isPossibleToAutoupdate = false;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return isPossibleToAutoupdate;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Storage::SetStartDownloadingCallback(StartDownloadingCallback const & cb)
|
||||
|
|
Loading…
Add table
Reference in a new issue