1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 12:44:42 +00:00

Increased VACUUM safety margin

This commit is contained in:
M66B 2020-06-28 14:02:14 +02:00
parent 98457c1c5d
commit f92ea9296a

View file

@ -229,12 +229,17 @@ public class WorkerCleanup extends Worker {
if (manual) {
// https://www.sqlite.org/lang_vacuum.html
long size = context.getDatabasePath(db.getOpenHelper().getDatabaseName()).length();
long space = Helper.getAvailableStorageSpace();
if (size * 2 < space) {
Log.i("Running VACUUM");
long available = Helper.getAvailableStorageSpace();
if (size > 0 && size * 2.5 < available) {
Log.i("Running VACUUM" +
" size=" + Helper.humanReadableByteCount(size, true) +
"/" + Helper.humanReadableByteCount(available, true));
db.getOpenHelper().getWritableDatabase().execSQL("VACUUM;");
} else
Log.w("Insufficient space for VACUUM");
Log.w("Insufficient space for VACUUM" +
" size=" + Helper.humanReadableByteCount(size, true) +
"/" + Helper.humanReadableByteCount(available, true));
}
} catch (Throwable ex) {