Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] explicitly set temp directory for SQLite3
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer authored and LukasPaczos committed Sep 26, 2018
1 parent 4148a5a commit 4004a85
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions platform/android/src/file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <mbgl/storage/resource_transform.hpp>
#include <mbgl/util/logging.hpp>

#include <sqlite3.hpp>

#include "asset_manager_file_source.hpp"

namespace mbgl {
Expand All @@ -17,6 +19,8 @@ FileSource::FileSource(jni::JNIEnv& _env,
const jni::String& accessToken,
const jni::String& _cachePath,
const jni::Object<AssetManager>& assetManager) {
mapbox::sqlite::setTempPath(jni::Make<std::string>(_env, _cachePath));

// Create a core default file source
fileSource = std::make_unique<mbgl::DefaultFileSource>(
jni::Make<std::string>(_env, _cachePath) + "/mbgl-offline.db",
Expand Down
4 changes: 4 additions & 0 deletions platform/default/sqlite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ static_assert(mbgl::underlying_type(ResultCode::Auth) == SQLITE_AUTH, "error");
static_assert(mbgl::underlying_type(ResultCode::Range) == SQLITE_RANGE, "error");
static_assert(mbgl::underlying_type(ResultCode::NotADB) == SQLITE_NOTADB, "error");

void setTempPath(const std::string& path) {
sqlite3_temp_directory = sqlite3_mprintf("%s", path.c_str());
}

class DatabaseImpl {
public:
DatabaseImpl(sqlite3* db_)
Expand Down
2 changes: 2 additions & 0 deletions platform/default/sqlite3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class StatementImpl;
class Query;
class Transaction;

void setTempPath(const std::string&);

class Database {
private:
Database(std::unique_ptr<DatabaseImpl>);
Expand Down

0 comments on commit 4004a85

Please sign in to comment.