[geary/wip/conversation-polish: 7/22] Retry fetching remote email body when loading but command times out
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/conversation-polish: 7/22] Retry fetching remote email body when loading but command times out
- Date: Tue, 29 Jan 2019 05:39:03 +0000 (UTC)
commit b9942cac9401a3c7c084944ad83b06be6de7f029
Author: Michael Gratton <mike vee net>
Date: Thu Jan 24 09:15:16 2019 +1100
Retry fetching remote email body when loading but command times out
.../conversation-viewer/conversation-email.vala | 55 +++++++++++++++-------
1 file changed, 38 insertions(+), 17 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index 297c382f..b354d233 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -596,7 +596,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
} catch (Geary.EngineError.INCOMPLETE_MESSAGE err) {
// Don't have the complete message at the moment, so
// download it in the background.
- this.fetch_body_remote.begin();
+ this.fetch_remote_body.begin();
}
this.body_loading_timeout.reset();
}
@@ -736,27 +736,48 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
});
}
- private async void fetch_body_remote()
+ private async void fetch_remote_body()
throws GLib.Error {
+ // Retry the remote fetch once if the first time fails, so if
+ // the connection has timed out we will establish a new one.
+ const int MAX_RETRIES = 2;
+
// XXX Need proper progress reporting here, rather than just
// doing a pulse
this.primary_message.start_progress_pulse();
+
+ int retries = 0;
Geary.Email? loaded = null;
- try {
- loaded = yield this.email_store.fetch_email_async(
- this.email.id,
- REQUIRED_FOR_LOAD,
- FORCE_UPDATE,
- this.load_cancellable
- );
- } catch (GLib.IOError.CANCELLED err) {
- // Don't stop message progress pulse here since if
- // cancelled, this could be well after the widgets have
- // been removed and destroyed
- } catch (GLib.Error err) {
- // XXX Notify user of a problem here
- debug("Remote message download failed: %s", err.message);
- this.primary_message.stop_progress_pulse();
+ while (retries < MAX_RETRIES) {
+ retries++;
+ try {
+ loaded = yield this.email_store.fetch_email_async(
+ this.email.id,
+ REQUIRED_FOR_LOAD,
+ FORCE_UPDATE,
+ this.load_cancellable
+ );
+ } catch (GLib.IOError.CANCELLED err) {
+ // Don't stop message progress pulse here since if
+ // cancelled, this could be well after the widgets have
+ // been removed and destroyed
+ throw err;
+ } catch (Geary.ImapError.TIMED_OUT err) {
+ if (retries < MAX_RETRIES) {
+ debug("Remote message download timed out, retrying: %s",
+ err.message);
+ } else {
+ debug("Remote message download timed out, giving up %s",
+ err.message);
+ this.primary_message.stop_progress_pulse();
+ throw err;
+ }
+ } catch (GLib.Error err) {
+ // XXX Notify user of a problem here
+ debug("Remote message download failed: %s", err.message);
+ this.primary_message.stop_progress_pulse();
+ throw err;
+ }
}
if (loaded != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]