mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 17:27:00 +00:00
Added option to disable sqlite auto vacuum
This commit is contained in:
parent
96c2b4af64
commit
e7364ed39c
4 changed files with 48 additions and 9 deletions
|
@ -408,13 +408,13 @@ public abstract class DB extends RoomDatabase {
|
|||
crumb.put("WAL", Boolean.toString(db.isWriteAheadLoggingEnabled()));
|
||||
Log.breadcrumb("Database", crumb);
|
||||
|
||||
if (BuildConfig.DEBUG || Helper.isRedmiNote()) {
|
||||
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
||||
// https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/
|
||||
Log.i("Set PRAGMA auto_vacuum = INCREMENTAL");
|
||||
try (Cursor cursor = db.query("PRAGMA auto_vacuum = INCREMENTAL;", null)) {
|
||||
cursor.moveToNext(); // required
|
||||
}
|
||||
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
||||
// https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/
|
||||
boolean sqlite_auto_vacuum = prefs.getBoolean("sqlite_auto_vacuum", !Helper.isRedmiNote());
|
||||
String mode = (sqlite_auto_vacuum ? "FULL" : "INCREMENTAL");
|
||||
Log.i("Set PRAGMA auto_vacuum = " + mode);
|
||||
try (Cursor cursor = db.query("PRAGMA auto_vacuum = " + mode + ";", null)) {
|
||||
cursor.moveToNext(); // required
|
||||
}
|
||||
|
||||
// https://www.sqlite.org/pragma.html#pragma_cache_size
|
||||
|
|
|
@ -151,6 +151,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private SwitchCompat swWal;
|
||||
private SwitchCompat swCheckpoints;
|
||||
private SwitchCompat swAnalyze;
|
||||
private SwitchCompat swAutoVacuum;
|
||||
private TextView tvSqliteCache;
|
||||
private SeekBar sbSqliteCache;
|
||||
private TextView tvChunkSize;
|
||||
|
@ -216,7 +217,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
"watchdog", "experiments", "main_log", "protocol", "log_level", "debug", "leak_canary", "test1",
|
||||
"test2", "test3", "test4", "test5",
|
||||
"work_manager", // "external_storage",
|
||||
"query_threads", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_cache",
|
||||
"query_threads", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_auto_vacuum", "sqlite_cache",
|
||||
"chunk_size", "thread_range", "undo_manager",
|
||||
"webview_legacy", "browser_zoom", "fake_dark",
|
||||
"show_recent",
|
||||
|
@ -331,6 +332,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swWal = view.findViewById(R.id.swWal);
|
||||
swCheckpoints = view.findViewById(R.id.swCheckpoints);
|
||||
swAnalyze = view.findViewById(R.id.swAnalyze);
|
||||
swAutoVacuum = view.findViewById(R.id.swAutoVacuum);
|
||||
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
|
||||
sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
|
||||
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
|
||||
|
@ -968,6 +970,17 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
swAutoVacuum.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton v, boolean checked) {
|
||||
prefs.edit()
|
||||
.putBoolean("sqlite_auto_vacuum", checked)
|
||||
.remove("debug")
|
||||
.apply();
|
||||
ApplicationEx.restart(v.getContext());
|
||||
}
|
||||
});
|
||||
|
||||
sbSqliteCache.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
@ -1761,6 +1774,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swWal.setChecked(prefs.getBoolean("wal", true));
|
||||
swCheckpoints.setChecked(prefs.getBoolean("sqlite_checkpoints", true));
|
||||
swAnalyze.setChecked(prefs.getBoolean("sqlite_analyze", true));
|
||||
swAutoVacuum.setChecked(prefs.getBoolean("sqlite_auto_vacuum", !Helper.isRedmiNote()));
|
||||
|
||||
int sqlite_cache = prefs.getInt("sqlite_cache", DB.DEFAULT_CACHE_SIZE);
|
||||
Integer cache_size = DB.getCacheSizeKb(getContext());
|
||||
|
|
|
@ -905,6 +905,30 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swCheckpoints"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoVacuum"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_auto_vacuum"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAnalyze"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAutoVacuumHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_english_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoVacuum" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSqliteCache"
|
||||
android:layout_width="0dp"
|
||||
|
@ -915,7 +939,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAnalyze" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAutoVacuumHint" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sbSqliteCache"
|
||||
|
|
|
@ -757,6 +757,7 @@
|
|||
<string name="title_advanced_wal" translatable="false">sqlite WAL</string>
|
||||
<string name="title_advanced_checkpoints" translatable="false">sqlite checkpoints</string>
|
||||
<string name="title_advanced_analyze" translatable="false">sqlite analyze</string>
|
||||
<string name="title_advanced_auto_vacuum" translatable="false">sqlite auto vacuum</string>
|
||||
<string name="title_advanced_sqlite_cache" translatable="false">sqlite cache: %1$s %% - %2$s</string>
|
||||
<string name="title_advanced_chunk_size" translatable="false">Chunk size: %1$d</string>
|
||||
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
|
||||
|
|
Loading…
Reference in a new issue