forked from Ivasoft/mattermost-mobile
66 lines
2.9 KiB
Diff
66 lines
2.9 KiB
Diff
diff --git a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
index ca31e20..b45c753 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
+++ b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
@@ -22,6 +22,21 @@ class Database(
|
|
if (name == ":memory:" || name.contains("mode=memory")) {
|
|
context.cacheDir.delete()
|
|
File(context.cacheDir, name).path
|
|
+ } else if (name.contains("/") || name.contains("file")) {
|
|
+ // Extracts the database name from the path
|
|
+ val dbName = name.substringAfterLast("/")
|
|
+
|
|
+ // Extracts the real path where the *.db file will be created
|
|
+ val truePath = name.substringAfterLast("file://").substringBeforeLast("/")
|
|
+
|
|
+ // Creates the directory
|
|
+ if (!truePath.contains("databases")) {
|
|
+ val fileObj = File(truePath, "databases")
|
|
+ fileObj.mkdir()
|
|
+ File("${truePath}/databases", dbName).path
|
|
+ } else {
|
|
+ File(truePath, dbName).path
|
|
+ }
|
|
} else {
|
|
// On some systems there is some kind of lock on `/databases` folder ¯\_(ツ)_/¯
|
|
context.getDatabasePath("$name.db").path.replace("/databases", "")
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
index a2bd410..44e1a58 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
@@ -54,6 +54,7 @@ void Database::destroy() {
|
|
const std::lock_guard<std::mutex> lock(mutex_);
|
|
|
|
if (isDestroyed_) {
|
|
+ db_->markAsDestroyed();
|
|
return;
|
|
}
|
|
isDestroyed_ = true;
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
index 4108e6c..0fa554c 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
@@ -69,6 +69,10 @@ void SqliteDb::destroy() {
|
|
}
|
|
}
|
|
|
|
+void SqliteDb::markAsDestroyed() {
|
|
+ isDestroyed_ = true;
|
|
+}
|
|
+
|
|
SqliteDb::~SqliteDb() {
|
|
destroy();
|
|
}
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
index 22cffa7..4b74a7f 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
@@ -11,6 +11,7 @@ public:
|
|
SqliteDb(std::string path);
|
|
~SqliteDb();
|
|
void destroy();
|
|
+ void markAsDestroyed();
|
|
|
|
sqlite3 *sqlite;
|
|
|