]> granicus.if.org Git - neomutt/commitdiff
Imap: Fix flag caching after sync.
authorKevin McCarthy <kevin@8t8.us>
Tue, 21 Jul 2015 19:34:49 +0000 (12:34 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 21 Jul 2015 19:34:49 +0000 (12:34 -0700)
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

index 93dc06a7f7b256793a181de77ed81fc02ef41fed..3a60a617f0edc4732170cc6a670d4f7e40d4a1d3 100644 (file)
@@ -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. */