[geary/wip/composer-folks] Make search update process optional when ImapDB.Account opened



commit 56e0fb7543c87af591efd15282e691e7bd25043d
Author: Michael Gratton <mike vee net>
Date:   Sun Jun 23 13:26:07 2019 +1000

    Make search update process optional when ImapDB.Account opened
    
    This allows ImapDB unit tests to avoid running the process when it
    really doesn't need to be run. Should fix anther criticial about
    ImapDB being null (see previous commit).

 src/engine/imap-db/imap-db-account.vala                 | 13 +------------
 src/engine/imap-engine/imap-engine-generic-account.vala | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 7748b28d..5b708d46 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -7,7 +7,6 @@
  */
 
 private class Geary.ImapDB.Account : BaseObject {
-    private const int POPULATE_SEARCH_TABLE_DELAY_SEC = 5;
 
     // These characters are chosen for being commonly used to continue a single word (such as
     // extended last names, i.e. "Lars-Eric") or in terms commonly searched for in an email client,
@@ -327,16 +326,6 @@ private class Geary.ImapDB.Account : BaseObject {
         }
 
         background_cancellable = new Cancellable();
-
-        // Kick off a background update of the search table, but since the database is getting
-        // hammered at startup, wait a bit before starting the update ... use the ordinal to
-        // stagger these being fired off (important for users with many accounts registered)
-        int account_sec = account_information.ordinal.clamp(0, 10);
-        Timeout.add_seconds(POPULATE_SEARCH_TABLE_DELAY_SEC + account_sec, () => {
-            populate_search_table_async.begin(background_cancellable);
-
-            return false;
-        });
     }
 
     public async void close_async(Cancellable? cancellable) throws Error {
@@ -1370,7 +1359,7 @@ private class Geary.ImapDB.Account : BaseObject {
         }, cancellable);
     }
 
-    private async void populate_search_table_async(Cancellable? cancellable) {
+    public async void populate_search_table(Cancellable? cancellable) {
         debug("%s: Populating search table", account_information.id);
         try {
             while (!yield populate_search_table_batch_async(50, cancellable)) {
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index ea303384..719142f4 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -167,6 +167,21 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         yield this.imap.start(cancellable);
         this.queue_operation(new StartPostie(this));
 
+        // Kick off a background update of the search table, but since
+        // the database is getting hammered at startup, wait a bit
+        // before starting the update ... use the ordinal to stagger
+        // these being fired off (important for users with many
+        // accounts registered).
+        //
+        // This is an example of an operation for which we need an
+        // engine-wide operation queue, not just an account-wide
+        // queue.
+        const int POPULATE_DELAY_SEC = 5;
+        int account_sec = this.information.ordinal.clamp(0, 10);
+        Timeout.add_seconds(POPULATE_DELAY_SEC + account_sec, () => {
+                this.local.populate_search_table.begin(cancellable);
+            return false;
+        });
     }
 
     public override async void close_async(Cancellable? cancellable = null) throws Error {


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