mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
Debug option to disable sqlite WAL
This commit is contained in:
parent
0263b15247
commit
d3f4f29d0c
6 changed files with 30 additions and 5 deletions
|
@ -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));
|
||||
|
|
|
@ -338,6 +338,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQueriesHint" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swWal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_wal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQueriesRemark"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swCrashReports"
|
||||
android:layout_width="0dp"
|
||||
|
@ -346,7 +357,7 @@
|
|||
android:text="@string/title_advanced_crash_reports"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQueriesRemark"
|
||||
app:layout_constraintTop_toBottomOf="@id/swWal"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
|
|
@ -531,6 +531,7 @@
|
|||
<string name="title_advanced_updates">Check for GitHub updates</string>
|
||||
<string name="title_advanced_experiments">Try experimental features</string>
|
||||
<string name="title_advanced_query_threads">Limit parallel database access</string>
|
||||
<string name="title_advanced_wal">WAL (debug only)</string>
|
||||
<string name="title_advanced_crash_reports">Send error reports</string>
|
||||
<string name="title_advanced_protocol">Protocol logging</string>
|
||||
<string name="title_advanced_debug">Debug mode</string>
|
||||
|
|
Loading…
Reference in a new issue