[geary: 27/66] Storage cleanup timing improvements



commit 872c7d7fd51563518b4fe78b00c2c2c37a160165
Author: Chris Heywood <15127-creywood users noreply gitlab gnome org>
Date:   Thu Jan 9 14:45:20 2020 +0100

    Storage cleanup timing improvements
    
    Ensure only one account is cleaned at a time - they're now cleaned in
    sequence. Also ensure re-entrancy isn't possible.
    (Geary.Account.last_storage_cleanup was previously assisting with
    this but is now unsufficient with the above change).

 src/client/application/application-controller.vala | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index a6cdaf2fa..14994d659 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -95,6 +95,9 @@ internal class Application.Controller : Geary.BaseObject {
     // Timeout to do work in idle after all windows have been sent to the background
     private Geary.TimeoutManager all_windows_backgrounded_timeout;
 
+    // Track whether storage cleanup is running
+    private bool storage_cleanup_running = false;
+
     // Whether we're fully in the background
     public bool all_windows_backgrounded { get; private set; default = false; }
 
@@ -1789,11 +1792,18 @@ internal class Application.Controller : Geary.BaseObject {
         this.all_windows_backgrounded = true;
         window_focus_out();
 
+        if (!storage_cleanup_running)
+            do_background_storage_cleanup.begin();
+    }
+
+    private async void do_background_storage_cleanup() {
         debug("Checking for backgrounded idle work");
+        storage_cleanup_running = true;
         foreach (AccountContext context in this.accounts.values) {
             Geary.Account account = context.account;
-            account.cleanup_storage.begin(context.cancellable);
+            yield account.cleanup_storage(context.cancellable);
         }
+        storage_cleanup_running = false;
     }
 
 }


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