From 7d58a41de5dbf1b24b8bad9a2a98c21a7bf75382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 7 Apr 2015 18:04:23 +0200 Subject: make sqlite storage more resilient to sporadic errors - catch SQLite exceptions and report them - failed statements are ignored, we're really just caching here, so if it fails we're handling it gracefully elsewhere - handle cases where the database file goes away after we opened it - handle cases where the schema wasn't created after the database file was opened successfully - add tests --- include/mbgl/platform/log.hpp | 4 +++- include/mbgl/storage/default/sqlite_cache.hpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp index 5d287eb572..d6f3cd1ab4 100644 --- a/include/mbgl/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -12,7 +13,7 @@ namespace mbgl { class Log { public: - class Observer { + class Observer : private util::noncopyable { public: virtual ~Observer() = default; @@ -22,6 +23,7 @@ public: }; static void setObserver(std::unique_ptr Observer); + static std::unique_ptr removeObserver(); private: template diff --git a/include/mbgl/storage/default/sqlite_cache.hpp b/include/mbgl/storage/default/sqlite_cache.hpp index 8f2746561c..fe80a41b52 100644 --- a/include/mbgl/storage/default/sqlite_cache.hpp +++ b/include/mbgl/storage/default/sqlite_cache.hpp @@ -38,6 +38,7 @@ private: void process(StopAction &action); void createDatabase(); + void createSchema(); const std::string path; uv_loop_t *loop = nullptr; @@ -45,6 +46,7 @@ private: std::thread thread; std::unique_ptr<::mapbox::sqlite::Database> db; std::unique_ptr<::mapbox::sqlite::Statement> getStmt, putStmt, refreshStmt; + bool schema = false; }; } -- cgit v1.2.1