Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-09-13 10:30:42 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-09-13 16:25:27 +0300
commitf9a4b1d4eb932c914be26b9e4cf68a12beb232ef (patch)
treeb4c604617e6d0e7a5e66cd5ec443db3a67ccfffd /storage
parent645a781cfbdb9047f9317e77eb031036344f9962 (diff)
Fixed downloading sizes considering of diffs.
Diffstat (limited to 'storage')
-rw-r--r--storage/diff_scheme/diff_manager.cpp8
-rw-r--r--storage/storage.cpp66
-rw-r--r--storage/storage.hpp3
3 files changed, 56 insertions, 21 deletions
diff --git a/storage/diff_scheme/diff_manager.cpp b/storage/diff_scheme/diff_manager.cpp
index c110e70b08..c401cc7a72 100644
--- a/storage/diff_scheme/diff_manager.cpp
+++ b/storage/diff_scheme/diff_manager.cpp
@@ -55,6 +55,7 @@ void Manager::ApplyDiff(ApplyDiffParams && p, std::function<void(bool const resu
auto & diffReadyPath = p.m_diffReadyPath;
auto & diffFile = p.m_diffFile;
+ auto const countryId = diffFile->GetCountryName();
bool result = false;
if (!my::RenameFileX(diffReadyPath, diffFile->GetPath(MapOptions::Diff)))
@@ -79,6 +80,13 @@ void Manager::ApplyDiff(ApplyDiffParams && p, std::function<void(bool const resu
m_status = Status::NotAvailable;
// TODO: Log the diff applying error (Downloader_DiffScheme_error (Aloha)).
}
+ else
+ {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ m_diffs.erase(countryId);
+ if (m_diffs.empty())
+ m_status = Status::NotAvailable;
+ }
task(result);
});
diff --git a/storage/storage.cpp b/storage/storage.cpp
index b49c606a72..782125f8bf 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -52,20 +52,6 @@ uint64_t GetLocalSize(shared_ptr<LocalCountryFile> file, MapOptions opt)
return size;
}
-uint64_t GetRemoteSize(CountryFile const & file, MapOptions opt, int64_t version)
-{
- if (version::IsSingleMwm(version))
- return opt == MapOptions::Nothing ? 0 : file.GetRemoteSize(MapOptions::Map);
-
- uint64_t size = 0;
- for (MapOptions bit : {MapOptions::Map, MapOptions::CarRouting})
- {
- if (HasOptions(opt, bit))
- size += file.GetRemoteSize(bit);
- }
- return size;
-}
-
void DeleteCountryIndexes(LocalCountryFile const & localFile)
{
platform::CountryIndexes::DeleteFromDisk(localFile);
@@ -839,9 +825,7 @@ void Storage::RegisterDownloadedFiles(TCountryId const & countryId, MapOptions f
GetPlatform().RunOnGuiThread([this, fn, diffFile, result]
{
if (result)
- {
RegisterCountryFiles(diffFile);
- }
fn(result);
});
@@ -1632,7 +1616,7 @@ MapFilesDownloader::TProgress Storage::CalculateProgress(
MapFilesDownloader::TProgress const & downloadingMwmProgress,
TCountriesSet const & mwmsInQueue) const
{
- // Function calculates progress correctly OLNY if |downloadingMwm| is leaf.
+ // Function calculates progress correctly ONLY if |downloadingMwm| is leaf.
MapFilesDownloader::TProgress localAndRemoteBytes = make_pair(0, 0);
@@ -1641,15 +1625,18 @@ MapFilesDownloader::TProgress Storage::CalculateProgress(
if (downloadingMwm == d && downloadingMwm != kInvalidCountryId)
{
localAndRemoteBytes.first += downloadingMwmProgress.first;
- localAndRemoteBytes.second += GetCountryFile(d).GetRemoteSize(MapOptions::Map);
+ localAndRemoteBytes.second += GetRemoteSize(GetCountryFile(d), MapOptions::Map,
+ GetCurrentDataVersion());
}
else if (mwmsInQueue.count(d) != 0)
{
- localAndRemoteBytes.second += GetCountryFile(d).GetRemoteSize(MapOptions::Map);
+ localAndRemoteBytes.second += GetRemoteSize(GetCountryFile(d), MapOptions::Map,
+ GetCurrentDataVersion());
}
else if (m_justDownloaded.count(d) != 0)
{
- TMwmSize const localCountryFileSz = GetCountryFile(d).GetRemoteSize(MapOptions::Map);
+ TMwmSize const localCountryFileSz = GetRemoteSize(GetCountryFile(d), MapOptions::Map,
+ GetCurrentDataVersion());
localAndRemoteBytes.first += localCountryFileSz;
localAndRemoteBytes.second += localCountryFileSz;
}
@@ -1700,7 +1687,18 @@ bool Storage::GetUpdateInfo(TCountryId const & countryId, UpdateInfo & updateInf
GetNodeStatus(descendantNode).status != NodeStatus::OnDiskOutOfDate)
return;
updateInfo.m_numberOfMwmFilesToUpdate += 1; // It's not a group mwm.
- updateInfo.m_totalUpdateSizeInBytes += descendantNode.Value().GetSubtreeMwmSizeBytes();
+ if (m_diffManager.GetStatus() == diffs::Status::Available &&
+ m_diffManager.HasDiffFor(descendantNode.Value().Name()))
+ {
+ updateInfo.m_totalUpdateSizeInBytes +=
+ m_diffManager.InfoFor(descendantNode.Value().Name()).m_size;
+ }
+ else
+ {
+ updateInfo.m_totalUpdateSizeInBytes +=
+ descendantNode.Value().GetSubtreeMwmSizeBytes();
+ }
+
TLocalAndRemoteSize sizes =
CountrySizeInBytes(descendantNode.Value().Name(), MapOptions::MapWithCarRouting);
updateInfo.m_sizeDifference +=
@@ -1799,6 +1797,7 @@ void Storage::GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & n
}
}
+
TCountryId const Storage::GetParentIdFor(TCountryId const & countryId) const
{
vector<TCountryTreeNode const *> nodes;
@@ -1817,4 +1816,29 @@ TCountryId const Storage::GetParentIdFor(TCountryId const & countryId) const
return nodes[0]->Value().GetParent();
}
+
+TMwmSize Storage::GetRemoteSize(CountryFile const & file, MapOptions opt,
+ int64_t version) const
+{
+ if (version::IsSingleMwm(version))
+ {
+ if (opt == MapOptions::Nothing)
+ return 0;
+
+ if (m_diffManager.GetStatus() == diffs::Status::Available &&
+ m_diffManager.HasDiffFor(file.GetName()))
+ {
+ return m_diffManager.InfoFor(file.GetName()).m_size;
+ }
+ return file.GetRemoteSize(MapOptions::Map);
+ }
+
+ TMwmSize size = 0;
+ for (MapOptions bit : {MapOptions::Map, MapOptions::CarRouting})
+ {
+ if (HasOptions(opt, bit))
+ size += file.GetRemoteSize(bit);
+ }
+ return size;
+}
} // namespace storage
diff --git a/storage/storage.hpp b/storage/storage.hpp
index e16b0e8571..a0dd850747 100644
--- a/storage/storage.hpp
+++ b/storage/storage.hpp
@@ -660,6 +660,9 @@ private:
void LoadDiffScheme();
void OnDiffStatusReceived() override;
+
+ TMwmSize GetRemoteSize(platform::CountryFile const & file, MapOptions opt,
+ int64_t version) const;
};
void GetQueuedCountries(Storage::TQueue const & queue, TCountriesSet & resultCountries);