summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-08-21 16:18:51 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-08-28 07:14:54 -0700
commiteb72fe580b61b68cb24f9ae57b210857a430bfdc (patch)
treeb06a02b83f8a6e3d77f9faa8b148186ce7ad67c9
parentbc806d4354e037e51881cd58c1dedf18a46146f9 (diff)
downloadqtlocation-mapboxgl-eb72fe580b61b68cb24f9ae57b210857a430bfdc.tar.gz
Require minimum side-loaded database user_version=6
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp10
-rw-r--r--test/storage/offline_database.test.cpp2
2 files changed, 7 insertions, 5 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index 8256912d39..a24c0cf912 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -652,11 +652,13 @@ OfflineDatabase::mergeDatabase(const std::string& sideDatabasePath) {
return unexpected<std::exception_ptr>(std::current_exception());
}
try {
- // Attaching an accessible path without a db file creates a new temporary
- //database and attaches it. Check for matching schema version.
+ // Support sideloaded databases at user_version = 6. Future schema version
+ // changes will need to implement migration paths for sideloaded databases at
+ // version 6.
auto sideUserVersion = static_cast<int>(getPragma<int64_t>("PRAGMA side.user_version"));
- if (sideUserVersion != 6) {
- throw std::runtime_error("Merge database does not match schema or has incorrect user_version");
+ const auto mainUserVersion = getPragma<int64_t>("PRAGMA user_version");
+ if (sideUserVersion < 6 || sideUserVersion != mainUserVersion) {
+ throw std::runtime_error("Merge database has incorrect user_version");
}
mapbox::sqlite::Transaction transaction(*db);
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index c9e3203abe..7511924d80 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -1277,7 +1277,7 @@ TEST(OfflineDatabase, MergeDatabaseWithInvalidPath) {
auto result = db.mergeDatabase(filename_sideload);
EXPECT_FALSE(result);
- EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Merge database does not match schema or has incorrect user_version" }));
+ EXPECT_EQ(1u, log.count({ EventSeverity::Error, Event::Database, -1, "Merge database has incorrect user_version" }));
EXPECT_EQ(0u, log.uncheckedCount());
}