diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-03-04 14:26:58 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-03-04 15:15:09 -0800 |
commit | eb9b4638417ddfb519cd278f25ad022500a9573a (patch) | |
tree | 996c51e79678510e2826bf93f3ff20a635cff9f2 /platform/default/mbgl/storage/offline_download.cpp | |
parent | 803adf42c9f8811598a2289c6b2773e968bebe30 (diff) | |
download | qtlocation-mapboxgl-eb9b4638417ddfb519cd278f25ad022500a9573a.tar.gz |
[core] Fix offline status reporting with pre-existing tiles (#4147)
Diffstat (limited to 'platform/default/mbgl/storage/offline_download.cpp')
-rw-r--r-- | platform/default/mbgl/storage/offline_download.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp index 8aa58d6c34..c748c1e572 100644 --- a/platform/default/mbgl/storage/offline_download.cpp +++ b/platform/default/mbgl/storage/offline_download.cpp @@ -134,7 +134,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const { } void OfflineDownload::activateDownload() { - status = offlineDatabase.getRegionCompletedStatus(id); + status = OfflineRegionStatus(); requiredSourceURLs.clear(); ensureResource(Resource::style(definition.styleURL), [&] (Response styleResponse) { @@ -188,10 +188,6 @@ void OfflineDownload::activateDownload() { ensureResource(resource); } }); - - // This will be the initial notification, after we've incremented requiredResourceCount - // to the reflect the extent to which required resources are already in the database. - observer->statusChanged(status); } void OfflineDownload::deactivateDownload() { @@ -207,14 +203,15 @@ void OfflineDownload::ensureTiles(SourceType type, uint16_t tileSize, const Sour void OfflineDownload::ensureResource(const Resource& resource, std::function<void (Response)> callback) { status.requiredResourceCount++; - optional<Response> offlineResponse = offlineDatabase.getRegionResource(id, resource); + optional<std::pair<Response, uint64_t>> offlineResponse = offlineDatabase.getRegionResource(id, resource); if (offlineResponse) { if (callback) { - callback(*offlineResponse); + callback(offlineResponse->first); } - // Not incrementing status.completedResource{Size,Count} here because previously-existing - // resources are already accounted for by offlineDatabase.getRegionCompletedStatus(); + status.completedResourceCount++; + status.completedResourceSize += offlineResponse->second; + observer->statusChanged(status); return; } |