[geary: 21/23] Fix racy crash adding just-removed emails to conversation monitor.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 21/23] Fix racy crash adding just-removed emails to conversation monitor.
- Date: Thu, 8 Feb 2018 07:31:06 +0000 (UTC)
commit 64b3eee6b400cea955728425bacbde347b878b07
Author: Michael James Gratton <mike vee net>
Date: Thu Feb 8 18:21:54 2018 +1100
Fix racy crash adding just-removed emails to conversation monitor.
* src/engine/app/app-conversation-monitor.vala (ConversationMonitor),
src/engine/app/conversation-monitor/app-conversation-set.vala
(ConversationSet): Don't try to add emails to a conversation if they
have no known paths - these may have been removed from the folder
between being listed and having their known paths discovered.
src/engine/app/app-conversation-monitor.vala | 10 +++--
.../conversation-monitor/app-conversation-set.vala | 40 ++++++++++----------
2 files changed, 26 insertions(+), 24 deletions(-)
---
diff --git a/src/engine/app/app-conversation-monitor.vala b/src/engine/app/app-conversation-monitor.vala
index f607317..5aac3cb 100644
--- a/src/engine/app/app-conversation-monitor.vala
+++ b/src/engine/app/app-conversation-monitor.vala
@@ -784,10 +784,12 @@ public class Geary.App.ConversationMonitor : BaseObject {
);
// Add them to the conversation set
- this.conversations.add_all_emails(
- job.emails.values, email_paths, this.base_folder,
- out added, out appended, out removed_due_to_merge
- );
+ if (email_paths != null) {
+ this.conversations.add_all_emails(
+ job.emails.values, email_paths, this.base_folder,
+ out added, out appended, out removed_due_to_merge
+ );
+ }
} catch (Error err) {
debug("Unable to add emails to conversation: %s", err.message);
diff --git a/src/engine/app/conversation-monitor/app-conversation-set.vala
b/src/engine/app/conversation-monitor/app-conversation-set.vala
index 624cd06..b6bd9ef 100644
--- a/src/engine/app/conversation-monitor/app-conversation-set.vala
+++ b/src/engine/app/conversation-monitor/app-conversation-set.vala
@@ -80,7 +80,7 @@ private class Geary.App.ConversationSet : BaseObject {
* being merged into another.
*/
public void add_all_emails(Gee.Collection<Email> emails,
- Gee.MultiMap<EmailIdentifier, FolderPath>? id_to_paths,
+ Gee.MultiMap<EmailIdentifier, FolderPath> id_to_paths,
Folder base_folder,
out Gee.Collection<Conversation> added,
out Gee.MultiMap<Conversation, Email> appended,
@@ -126,27 +126,27 @@ private class Geary.App.ConversationSet : BaseObject {
foreach (Geary.Email moved in moved_email)
_appended.set(dest, moved);
}
-
- // Nasty ol' Email won't cause problems now -- but let's check anyway!
- assert(get_associated_conversations(email).size <= 1);
}
- bool added_conversation;
- Conversation? conversation = add_email(
- email,
- base_folder,
- (id_to_paths != null) ? id_to_paths.get(email.id) : null,
- out added_conversation
- );
-
- if (conversation == null)
- continue;
+ Conversation? conversation = null;
+ bool added_conversation = false;
+ Gee.Collection<Geary.FolderPath>? known_paths = id_to_paths.get(email.id);
+ if (known_paths != null) {
+ // Don't add an email with no known paths - it may
+ // have been removed after being listed for adding.
+ conversation = add_email(
+ email, base_folder, known_paths,
+ out added_conversation
+ );
+ }
- if (added_conversation) {
- _added.add(conversation);
- } else {
- if (!_added.contains(conversation))
- _appended.set(conversation, email);
+ if (conversation != null) {
+ if (added_conversation) {
+ _added.add(conversation);
+ } else {
+ if (!_added.contains(conversation))
+ _appended.set(conversation, email);
+ }
}
}
@@ -375,7 +375,7 @@ private class Geary.App.ConversationSet : BaseObject {
Geary.Email? email = conversation.get_email_by_id(id);
switch (conversation.get_folder_count(id)) {
case 0:
- error("Unable to locate email %s in conversation %s",
+ error("Email %s conversation %s not in any folders",
id.to_string(), conversation.to_string());
case 1:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]