mirror of https://github.com/M66B/FairEmail.git
Added option to disable sqlite auto vacuum
This commit is contained in:
parent
96c2b4af64
commit
e7364ed39c
|
@ -408,13 +408,13 @@ public abstract class DB extends RoomDatabase {
|
||||||
crumb.put("WAL", Boolean.toString(db.isWriteAheadLoggingEnabled()));
|
crumb.put("WAL", Boolean.toString(db.isWriteAheadLoggingEnabled()));
|
||||||
Log.breadcrumb("Database", crumb);
|
Log.breadcrumb("Database", crumb);
|
||||||
|
|
||||||
if (BuildConfig.DEBUG || Helper.isRedmiNote()) {
|
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
||||||
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
|
// https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/
|
||||||
// https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/
|
boolean sqlite_auto_vacuum = prefs.getBoolean("sqlite_auto_vacuum", !Helper.isRedmiNote());
|
||||||
Log.i("Set PRAGMA auto_vacuum = INCREMENTAL");
|
String mode = (sqlite_auto_vacuum ? "FULL" : "INCREMENTAL");
|
||||||
try (Cursor cursor = db.query("PRAGMA auto_vacuum = INCREMENTAL;", null)) {
|
Log.i("Set PRAGMA auto_vacuum = " + mode);
|
||||||
cursor.moveToNext(); // required
|
try (Cursor cursor = db.query("PRAGMA auto_vacuum = " + mode + ";", null)) {
|
||||||
}
|
cursor.moveToNext(); // required
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.sqlite.org/pragma.html#pragma_cache_size
|
// 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 swWal;
|
||||||
private SwitchCompat swCheckpoints;
|
private SwitchCompat swCheckpoints;
|
||||||
private SwitchCompat swAnalyze;
|
private SwitchCompat swAnalyze;
|
||||||
|
private SwitchCompat swAutoVacuum;
|
||||||
private TextView tvSqliteCache;
|
private TextView tvSqliteCache;
|
||||||
private SeekBar sbSqliteCache;
|
private SeekBar sbSqliteCache;
|
||||||
private TextView tvChunkSize;
|
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",
|
"watchdog", "experiments", "main_log", "protocol", "log_level", "debug", "leak_canary", "test1",
|
||||||
"test2", "test3", "test4", "test5",
|
"test2", "test3", "test4", "test5",
|
||||||
"work_manager", // "external_storage",
|
"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",
|
"chunk_size", "thread_range", "undo_manager",
|
||||||
"webview_legacy", "browser_zoom", "fake_dark",
|
"webview_legacy", "browser_zoom", "fake_dark",
|
||||||
"show_recent",
|
"show_recent",
|
||||||
|
@ -331,6 +332,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
swWal = view.findViewById(R.id.swWal);
|
swWal = view.findViewById(R.id.swWal);
|
||||||
swCheckpoints = view.findViewById(R.id.swCheckpoints);
|
swCheckpoints = view.findViewById(R.id.swCheckpoints);
|
||||||
swAnalyze = view.findViewById(R.id.swAnalyze);
|
swAnalyze = view.findViewById(R.id.swAnalyze);
|
||||||
|
swAutoVacuum = view.findViewById(R.id.swAutoVacuum);
|
||||||
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
|
tvSqliteCache = view.findViewById(R.id.tvSqliteCache);
|
||||||
sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
|
sbSqliteCache = view.findViewById(R.id.sbSqliteCache);
|
||||||
ibSqliteCache = view.findViewById(R.id.ibSqliteCache);
|
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() {
|
sbSqliteCache.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
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));
|
swWal.setChecked(prefs.getBoolean("wal", true));
|
||||||
swCheckpoints.setChecked(prefs.getBoolean("sqlite_checkpoints", true));
|
swCheckpoints.setChecked(prefs.getBoolean("sqlite_checkpoints", true));
|
||||||
swAnalyze.setChecked(prefs.getBoolean("sqlite_analyze", 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);
|
int sqlite_cache = prefs.getInt("sqlite_cache", DB.DEFAULT_CACHE_SIZE);
|
||||||
Integer cache_size = DB.getCacheSizeKb(getContext());
|
Integer cache_size = DB.getCacheSizeKb(getContext());
|
||||||
|
|
|
@ -905,6 +905,30 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/swCheckpoints"
|
app:layout_constraintTop_toBottomOf="@id/swCheckpoints"
|
||||||
app:switchPadding="12dp" />
|
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
|
<TextView
|
||||||
android:id="@+id/tvSqliteCache"
|
android:id="@+id/tvSqliteCache"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -915,7 +939,7 @@
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/swAnalyze" />
|
app:layout_constraintTop_toBottomOf="@id/tvAutoVacuumHint" />
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/sbSqliteCache"
|
android:id="@+id/sbSqliteCache"
|
||||||
|
|
|
@ -757,6 +757,7 @@
|
||||||
<string name="title_advanced_wal" translatable="false">sqlite WAL</string>
|
<string name="title_advanced_wal" translatable="false">sqlite WAL</string>
|
||||||
<string name="title_advanced_checkpoints" translatable="false">sqlite checkpoints</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_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_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_chunk_size" translatable="false">Chunk size: %1$d</string>
|
||||||
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
|
<string name="title_advanced_thread_range" translatable="false">Thread range: %1$d days</string>
|
||||||
|
|
Loading…
Reference in New Issue