[geary/geary-0.13] Merge branch 'wip/goa-error-when-disconnected' into 'master'



commit 94c4ee4360d966aa11f95de538516d28837340fc
Author: Michael Gratton <mike vee net>
Date:   Mon Mar 4 22:05:33 2019 +0000

    Merge branch 'wip/goa-error-when-disconnected' into 'master'
    
    Fix GOA accounts throwing an error when starting offline
    
    See merge request GNOME/geary!161
    
    (cherry picked from commit c8f5e0295ce5390d7418d1aae98601f686139e0f)
    
    82160e9f Fix GOA accounts throwing an error when starting offline

 src/engine/imap-engine/imap-engine-generic-account.vala |  5 -----
 src/engine/imap/api/imap-client-service.vala            | 14 ++++++++++++++
 src/engine/smtp/smtp-client-service.vala                |  4 ++++
 3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 165254d0..0ca058f5 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -160,11 +160,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             new LoadFolders(this, this.local, get_supported_special_folders())
         );
 
-        // To prevent spurious connection failures, we make sure we
-        // have passwords before attempting a connection.
-        yield this.information.load_incoming_credentials(cancellable);
-        yield this.information.load_outgoing_credentials(cancellable);
-
         // Start the mail services. Start incoming directly, but queue
         // outgoing so local folders can be loaded first in case
         // queued mail gets sent and needs to get saved somewhere.
diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala
index fa99d478..3b36043c 100644
--- a/src/engine/imap/api/imap-client-service.vala
+++ b/src/engine/imap/api/imap-client-service.vala
@@ -265,6 +265,20 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
         debug("Checking session pool with %d of %d free",
               this.free_queue.size, this.all_sessions.size);
 
+        if (!is_claiming) {
+            // To prevent spurious connection failures, ensure tokens
+            // are up-to-date before attempting a connection, but
+            // after we know we should be able to connect to it
+            try {
+                yield this.account.load_incoming_credentials(
+                    this.pool_cancellable
+                );
+            } catch (GLib.Error err) {
+                notify_connection_failed(new ErrorContext(err));
+                return;
+            }
+        }
+
         int needed = this.min_pool_size - this.all_sessions.size;
         if (needed <= 0 && is_claiming) {
             needed = 1;
diff --git a/src/engine/smtp/smtp-client-service.vala b/src/engine/smtp/smtp-client-service.vala
index e949338a..bd22190a 100644
--- a/src/engine/smtp/smtp-client-service.vala
+++ b/src/engine/smtp/smtp-client-service.vala
@@ -188,6 +188,10 @@ internal class Geary.Smtp.ClientService : Geary.ClientService {
     // Returns true if email was successfully processed, else false
     private async void process_email(EmailIdentifier id, Cancellable cancellable)
         throws GLib.Error {
+        // To prevent spurious connection failures, ensure tokens are
+        // up-to-date before attempting to send the email
+        yield this.account.load_outgoing_credentials(cancellable);
+
         Email? email = null;
         try {
             email = yield this.outbox.fetch_email_async(


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