From bb8c7ecafeef9936453914e8cdbf64446202cc1a Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 Jun 2022 13:46:15 +0200 Subject: [PATCH] Added sync --- app/src/main/java/eu/faircode/email/Helper.java | 6 ++++++ app/src/main/java/eu/faircode/email/WorkerFts.java | 4 +++- app/src/main/jni/fairemail.cc | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 3c131d8059..60eaa044b5 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -2051,6 +2051,12 @@ public class Helper { // Files + static { + System.loadLibrary("fairemail"); + } + + public static native void sync(); + static String sanitizeFilename(String name) { if (name == null) return null; diff --git a/app/src/main/java/eu/faircode/email/WorkerFts.java b/app/src/main/java/eu/faircode/email/WorkerFts.java index 9890c42923..b29727996d 100644 --- a/app/src/main/java/eu/faircode/email/WorkerFts.java +++ b/app/src/main/java/eu/faircode/email/WorkerFts.java @@ -109,8 +109,10 @@ public class WorkerFts extends Worker { markIndexed(db, ids); - if (checkpoints) + if (checkpoints) { DB.checkpoint(context); + Helper.sync(); + } Log.i("FTS indexed=" + indexed); return Result.success(); diff --git a/app/src/main/jni/fairemail.cc b/app/src/main/jni/fairemail.cc index 9af3ec9d26..f6e6849b4c 100644 --- a/app/src/main/jni/fairemail.cc +++ b/app/src/main/jni/fairemail.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include "compact_enc_det/compact_enc_det.h" #include "cld_3/src/nnet_language_identifier.h" @@ -200,3 +201,11 @@ Java_eu_faircode_email_ConnectionHelper_jni_1is_1numeric_1address( env->ReleaseStringUTFChars(_ip, ip); return numeric; } + +extern "C" +JNIEXPORT void JNICALL +Java_eu_faircode_email_Helper_sync(JNIEnv *env, jclass clazz) { + log_android(ANDROID_LOG_DEBUG, "sync"); + sync(); + log_android(ANDROID_LOG_DEBUG, "synced"); +}