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:
parent
98457c1c5d
commit
f92ea9296a
1 changed files with 9 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue