Moved vacuum to cleanup

This commit is contained in:
M66B 2020-01-20 20:29:32 +01:00
parent 0b7e5a8e21
commit d91a30293a
3 changed files with 7 additions and 15 deletions

View File

@ -130,18 +130,6 @@ public abstract class DB extends RoomDatabase {
sInstance = migrate(acontext, getBuilder(acontext));
// https://www.sqlite.org/lang_vacuum.html
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean vacuum = prefs.getBoolean("vacuum", false);
if (vacuum)
try {
Log.i("Running VACUUM");
sInstance.getOpenHelper().getWritableDatabase().execSQL("VACUUM;");
prefs.edit().remove("vacuum").apply();
} catch (Throwable ex) {
Log.e(ex);
}
sInstance.getInvalidationTracker().addObserver(new InvalidationTracker.Observer(
EntityAccount.TABLE_NAME,
EntityIdentity.TABLE_NAME,

View File

@ -339,9 +339,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
@Override
protected Void onExecute(Context context, Bundle args) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("vacuum", true).apply();
WorkerCleanup.cleanup(context, true);
return null;
}

View File

@ -221,6 +221,13 @@ public class WorkerCleanup extends Worker {
Log.i("Cleanup log");
int logs = db.log().deleteLogs(now - KEEP_LOG_DURATION);
Log.i("Deleted logs=" + logs);
if (manual) {
// https://www.sqlite.org/lang_vacuum.html
Log.i("Running VACUUM");
db.getOpenHelper().getWritableDatabase().execSQL("VACUUM;");
}
} catch (Throwable ex) {
Log.e(ex);
} finally {