From f92ea9296a931ba68e5a32641dc16b036fb9b63b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 28 Jun 2020 14:02:14 +0200 Subject: [PATCH] Increased VACUUM safety margin --- .../main/java/eu/faircode/email/WorkerCleanup.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 783d87a0c8..dd9498e296 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -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) {