Merge branch 'wip/goa-error-when-disconnected' into 'master'

Fix GOA accounts throwing an error when starting offline

See merge request GNOME/geary!161
This commit is contained in:
Michael Gratton 2019-03-04 22:05:33 +00:00
commit c8f5e0295c
3 changed files with 18 additions and 5 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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(