Commit 82160e9f authored by Michael Gratton's avatar Michael Gratton 🤞

Fix GOA accounts throwing an error when starting offline

Don't check service credentials are loaded when the account is being
opened, since GOA accounts will do a
org.gnome.OnlineAccounts.Account::EnsureCredentials() call, and this
will error out if the creds are invalid or not available.

Instead, check when we know that the services should be reachable, and
hope that means the GOA provider's auth service is reachable, too.
parent 224ccb18
Pipeline #64747 passed with stages
in 24 minutes and 21 seconds
......@@ -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.
......
......@@ -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;
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment