mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-12 12:03:17 +02:00
Debug option to disable sqlite WAL
This commit is contained in:
@@ -993,7 +993,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
||||
if ("secure".equals(key) ||
|
||||
"shortcuts".equals(key) ||
|
||||
"language".equals(key) ||
|
||||
"query_threads".equals(key))
|
||||
"query_threads".equals(key) ||
|
||||
"wal".equals(key))
|
||||
continue;
|
||||
|
||||
if (key != null && key.startsWith("widget."))
|
||||
|
||||
@@ -196,6 +196,7 @@ public class ApplicationEx extends Application
|
||||
case "shortcuts": // misc
|
||||
case "language": // misc
|
||||
case "query_threads": // misc
|
||||
case "wal": // misc
|
||||
// Should be excluded for import
|
||||
restart();
|
||||
break;
|
||||
|
||||
@@ -266,14 +266,15 @@ public abstract class DB extends RoomDatabase {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int threads = prefs.getInt("query_threads", 4); // AndroidX default thread count: 4
|
||||
Log.i("Query threads=" + threads);
|
||||
boolean wal = prefs.getBoolean("wal", true);
|
||||
Log.i("DB query threads=" + threads + " wal=" + wal);
|
||||
ExecutorService executor = Helper.getBackgroundExecutor(threads, "query");
|
||||
|
||||
return Room
|
||||
.databaseBuilder(context, DB.class, DB_NAME)
|
||||
.openHelperFactory(new RequerySQLiteOpenHelperFactory())
|
||||
.setQueryExecutor(executor)
|
||||
.setJournalMode(JournalMode.WRITE_AHEAD_LOGGING) // using the latest sqlite
|
||||
.setJournalMode(wal ? JournalMode.WRITE_AHEAD_LOGGING : JournalMode.TRUNCATE) // using the latest sqlite
|
||||
.addCallback(new Callback() {
|
||||
@Override
|
||||
public void onOpen(@NonNull SupportSQLiteDatabase db) {
|
||||
|
||||
@@ -98,6 +98,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private SwitchCompat swExperiments;
|
||||
private TextView tvExperimentsHint;
|
||||
private SwitchCompat swQueries;
|
||||
private SwitchCompat swWal;
|
||||
private SwitchCompat swCrashReports;
|
||||
private TextView tvUuid;
|
||||
private Button btnReset;
|
||||
@@ -133,7 +134,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
"shortcuts", "fts",
|
||||
"classification", "class_min_probability", "class_min_difference",
|
||||
"language", "watchdog", "updates",
|
||||
"experiments", "query_threads", "crash_reports", "cleanup_attachments",
|
||||
"experiments", "wal", "query_threads", "crash_reports", "cleanup_attachments",
|
||||
"protocol", "debug", "perform_expunge", "auth_plain", "auth_login", "auth_ntlm", "auth_sasl"
|
||||
};
|
||||
|
||||
@@ -193,6 +194,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
swExperiments = view.findViewById(R.id.swExperiments);
|
||||
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
|
||||
swQueries = view.findViewById(R.id.swQueries);
|
||||
swWal = view.findViewById(R.id.swWal);
|
||||
swCrashReports = view.findViewById(R.id.swCrashReports);
|
||||
tvUuid = view.findViewById(R.id.tvUuid);
|
||||
btnReset = view.findViewById(R.id.btnReset);
|
||||
@@ -404,6 +406,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
}
|
||||
});
|
||||
|
||||
swWal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("wal", checked).commit(); // apply won't work here
|
||||
}
|
||||
});
|
||||
|
||||
swCrashReports.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -852,6 +861,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
? View.GONE : View.VISIBLE);
|
||||
swExperiments.setChecked(prefs.getBoolean("experiments", false));
|
||||
swQueries.setChecked(prefs.getInt("query_threads", 4) < 4);
|
||||
swWal.setChecked(prefs.getBoolean("wal", true));
|
||||
swCrashReports.setChecked(prefs.getBoolean("crash_reports", false));
|
||||
tvUuid.setText(prefs.getString("uuid", null));
|
||||
swCleanupAttachments.setChecked(prefs.getBoolean("cleanup_attachments", false));
|
||||
|
||||
Reference in New Issue
Block a user