From 5e0d25561c4f9637b0ceaa9e9b600f3fe6eace73 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 21 Jul 2015 12:34:49 -0700 Subject: [PATCH] Imap: Fix flag caching after sync. The flags cached in IMAP_HEADER_DATA were not updated to match the HEADER flags after a sync. This means if a flag were toggled and synced twice, the second sync was not sending the flag update. Thanks to Noah Misch for the patch. --- imap/imap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imap/imap.c b/imap/imap.c index 93dc06a7f..3a60a617f 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1281,8 +1281,18 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint) goto out; } + /* Update local record of server state to reflect the synchronization just + * completed. imap_read_headers always overwrites hcache-origin flags, so + * there is no need to mutate the hcache after flag-only changes. */ for (n = 0; n < ctx->msgcount; n++) + { + HEADER_DATA(ctx->hdrs[n])->deleted = ctx->hdrs[n]->deleted; + HEADER_DATA(ctx->hdrs[n])->flagged = ctx->hdrs[n]->flagged; + HEADER_DATA(ctx->hdrs[n])->old = ctx->hdrs[n]->old; + HEADER_DATA(ctx->hdrs[n])->read = ctx->hdrs[n]->read; + HEADER_DATA(ctx->hdrs[n])->replied = ctx->hdrs[n]->replied; ctx->hdrs[n]->changed = 0; + } ctx->changed = 0; /* We must send an EXPUNGE command if we're not closing. */ -- 2.40.0