[geary: 12/66] After GC reap check for a vacuum



commit 47bdda6af59eeee160823fb0d6227862eed1c59a
Author: Chris Heywood <15127-creywood users noreply gitlab gnome org>
Date:   Wed Jan 8 13:02:22 2020 +0100

    After GC reap check for a vacuum
    
    The idea here being if we've just reduced prefetch period, reap has
    detached a whole lot of messages and we want to vacuum. This check
    catches that vacuum recommendation, flagging it to run when the app
    is backgrounded and idle.

 src/engine/imap-db/imap-db-database.vala | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/src/engine/imap-db/imap-db-database.vala b/src/engine/imap-db/imap-db-database.vala
index f91d0bea0..5e0fc0ab6 100644
--- a/src/engine/imap-db/imap-db-database.vala
+++ b/src/engine/imap-db/imap-db-database.vala
@@ -172,6 +172,24 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
                     this.path, err.message);
         }
 
+        // Check if after reap we now want to schedule a background vacuum. The idea
+        // here is eg. if we've just reduced prefetch period, reap has detached a
+        // whole lot of messages and we want to vacuum. This check catches that
+        // vacuum recommendation, flagging it to run when in background.
+        this.gc.should_run_async.begin(
+            gc_cancellable,
+            (obj, res) => {
+                try {
+                    GC.RecommendedOperation recommended = this.gc.should_run_async.end(res);
+                    if ((recommended & GC.RecommendedOperation.VACUUM) != 0)
+                        this.want_background_vacuum = true;
+                } catch (Error err) {
+                    debug("Failed to run GC check on %s after REAP: %s",
+                          this.path, err.message);
+                }
+            }
+        );
+
         this.gc = null;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]