From 9874b4515f503bf144a5a0b8bcb3e8ecbefbbd9c Mon Sep 17 00:00:00 2001 From: James Magahern Date: Thu, 28 Feb 2019 23:45:59 -0800 Subject: [PATCH] Fixes an issue where updating flags on a folder being opened doesn't update local folder When a folder is being opened for the first time, ImapEngine.Folder.update_flags is called to refresh the flags for all the messages in that folder. When the flags are updated, the `notify_email_flags_changed` signal is called, which in turn notifies the conversation monitor that the flags have changed and is thus appropriately updated. However, these flag changes are never persisted to the local database because the local folder is not updated if these flags changed. This has a bad effect for messages that are deleted *since* the last time you opened that mailbox, because it means if you open a folder containing messages that have the \DELETED flag set, once `update_flags` is called, they get evaporated from the conversation monitor as expected, however if you navigate away from that folder and return to it later, the message returns. Steps to reproduce: 1. Open a mailbox in the UI containing some messages 2. Quit Geary 3. Mark one of the messages in that mailbox as \DELETED using another mail client ('d' in mutt, sync with $, don't purge). 4. Re-launch Geary --> RESULT: Geary launches, mailbox is refreshed, deleted message disappears (expected) 5. Navigate to another mailbox 6. Navigate back to previous mailbox --> RESULT: Message that was deleted has returned. This patch simply ensures `set_email_flags_async` is called on the local folder if the remote list operation indicates there were flags that have changed, thus ensuring the flag changes are persisted to the database. Normally this happens with an imap-replay-operation, but since this was an explicit update call, no replay operation is scheduled. Testing: Ran all client and engine tests, all passing on my machine. --- src/engine/imap-engine/imap-engine-minimal-folder.vala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala b/src/engine/imap-engine/imap-engine-minimal-folder.vala index e76c19875..f33b93fe8 100644 --- a/src/engine/imap-engine/imap-engine-minimal-folder.vala +++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala @@ -1503,9 +1503,13 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport changed_map.set(e.id, e.email_flags); } - if (!cancellable.is_cancelled() && changed_map.size > 0) + if (!cancellable.is_cancelled() && changed_map.size > 0) { notify_email_flags_changed(changed_map); + // Also update local folder + yield local_folder.set_email_flags_async(changed_map as Gee.Map, null); + } + chunk_size *= 2; if (chunk_size > FLAG_UPDATE_MAX_CHUNK) { chunk_size = FLAG_UPDATE_MAX_CHUNK; -- GitLab