diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-29 14:10:41 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-29 17:28:51 +0300 |
commit | 0c80f3a383ba7a9844fa5f2379bb900d462fdd0e (patch) | |
tree | 50f6211e29ada6b20fc703fbeb383b549a4ffad0 | |
parent | 62e1e03c09bbcd0240ed4bd7eeacc156d6b94cc3 (diff) | |
download | qtlocation-mapboxgl-0c80f3a383ba7a9844fa5f2379bb900d462fdd0e.tar.gz |
[core] Add OfflineDatabase::markUsedResources()
-rw-r--r-- | platform/default/include/mbgl/storage/offline_database.hpp | 1 | ||||
-rw-r--r-- | platform/default/src/mbgl/storage/offline_database.cpp | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/platform/default/include/mbgl/storage/offline_database.hpp b/platform/default/include/mbgl/storage/offline_database.hpp index afce87b542..fe286575a4 100644 --- a/platform/default/include/mbgl/storage/offline_database.hpp +++ b/platform/default/include/mbgl/storage/offline_database.hpp @@ -92,6 +92,7 @@ public: bool offlineMapboxTileCountLimitExceeded(); uint64_t getOfflineMapboxTileCount(); bool exceedsOfflineMapboxTileCountLimit(const Resource&); + void markUsedResources(int64_t regionID, const std::list<Resource>&); private: void initialize(); diff --git a/platform/default/src/mbgl/storage/offline_database.cpp b/platform/default/src/mbgl/storage/offline_database.cpp index d85b560d5a..31442c1bde 100644 --- a/platform/default/src/mbgl/storage/offline_database.cpp +++ b/platform/default/src/mbgl/storage/offline_database.cpp @@ -1278,6 +1278,19 @@ bool OfflineDatabase::exceedsOfflineMapboxTileCountLimit(const Resource& resourc && offlineMapboxTileCountLimitExceeded(); } +void OfflineDatabase::markUsedResources(int64_t regionID, const std::list<Resource>& resources) try { + if (!db) { + initialize(); + } + mapbox::sqlite::Transaction transaction(*db); + for (const auto& resource : resources) { + markUsed(regionID, resource); + } + transaction.commit(); +} catch (const mapbox::sqlite::Exception& ex) { + handleError(ex, "mark resources as used"); +} + std::exception_ptr OfflineDatabase::resetDatabase() try { removeExisting(); initialize(); |