[geary/wip/conversation-polish: 6/26] Modernise FetchOperation somewhat
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/conversation-polish: 6/26] Modernise FetchOperation somewhat
- Date: Sat, 2 Feb 2019 02:10:29 +0000 (UTC)
commit 5fea5c8d595e71df2ef04586ea0e59f2f46379ef
Author: Michael Gratton <mike vee net>
Date: Thu Jan 24 18:52:52 2019 +1100
Modernise FetchOperation somewhat
Tidy up the op's implementation, don't bother throwing new errors in
MinimalFolder, they should be covered by the op.
.../imap-engine/imap-engine-minimal-folder.vala | 21 +++++++++------------
.../replay-ops/imap-engine-fetch-email.vala | 22 +++++++++++-----------
2 files changed, 20 insertions(+), 23 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index e9204bba..bef43a4a 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -1185,20 +1185,17 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
check_open("fetch_email_async");
check_flags("fetch_email_async", flags);
check_id("fetch_email_async", id);
-
- FetchEmail op = new FetchEmail(this, (ImapDB.EmailIdentifier) id, required_fields, flags,
- cancellable);
+
+ FetchEmail op = new FetchEmail(
+ this,
+ (ImapDB.EmailIdentifier) id,
+ required_fields,
+ flags,
+ cancellable
+ );
replay_queue.schedule(op);
-
+
yield op.wait_for_ready_async(cancellable);
-
- if (op.email == null) {
- throw new EngineError.NOT_FOUND("Email %s not found in %s", id.to_string(), to_string());
- } else if (!op.email.fields.fulfills(required_fields)) {
- throw new EngineError.INCOMPLETE_MESSAGE("Email %s in %s does not fulfill required fields %Xh
(has %Xh)",
- id.to_string(), to_string(), required_fields, op.email.fields);
- }
-
return op.email;
}
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
b/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
index 6c0d21bb..d5e3ed95 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
@@ -49,6 +49,7 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
return CONTINUE;
}
+ Geary.Email? email = null;
try {
email = yield engine.local_folder.fetch_email_async(id, required_fields,
ImapDB.Folder.ListFlags.PARTIAL_OK, cancellable);
@@ -57,15 +58,17 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
if (!(err is Geary.EngineError.NOT_FOUND) && !(err is Geary.EngineError.INCOMPLETE_MESSAGE))
throw err;
}
-
+
// If returned in full, done
- if (email != null && email.fields.fulfills(required_fields))
+ if (email.fields.fulfills(required_fields)) {
+ this.email = email;
return ReplayOperation.Status.COMPLETED;
+ }
// If local only, ensure the email has all required fields
if (flags.is_all_set(Folder.ListFlags.LOCAL_ONLY)) {
throw new EngineError.INCOMPLETE_MESSAGE(
- "Email %s with fields %Xh not found in %s",
+ "Email %s with fields %Xh locally incomplete %s",
id.to_string(),
required_fields,
to_string()
@@ -104,16 +107,13 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
new Imap.MessageSet.uid(uid), remaining_fields, cancellable);
if (list == null || list.size != 1)
throw new EngineError.NOT_FOUND("Unable to fetch %s in %s", id.to_string(), engine.to_string());
-
- // save to local store
- email = list[0];
- assert(email != null);
-
+
Gee.Map<Geary.Email, bool> created_or_merged =
yield engine.local_folder.create_or_merge_email_async(
- Geary.iterate<Geary.Email>(email).to_array_list(), cancellable);
-
- // true means created
+ list, cancellable
+ );
+
+ Geary.Email email = list[0];
if (created_or_merged.get(email)) {
Gee.Collection<Geary.EmailIdentifier> ids
= Geary.iterate<Geary.EmailIdentifier>(email.id).to_array_list();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]