]> granicus.if.org Git - neomutt/commitdiff
Only sync CONDSTORE and QRESYNC on the initial download.
authorKevin McCarthy <kevin@8t8.us>
Mon, 13 Aug 2018 16:43:55 +0000 (09:43 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 3 Sep 2018 15:38:30 +0000 (16:38 +0100)
In the midst of the imap_read_headers() refactor, I forgot to put this
guard on the /MODSEQ and /UIDSEQSET storage.

Because we don't deal with flag sync issues while the mailbox is open,
or when it closes, we only want to write those values to the header
cache during the initial download.

It makes no sense to perform all the header cache work if new messages
come into an open empty mailbox, so add a parameter to flag the
initial download, rather than check for msn_begin==1.

imap/command.c
imap/imap.c
imap/imap_private.h
imap/message.c

index c8be2511244a40629ace8557600bae1cd1856f1b..bfefd4acd662a82bb40702103f84bf32318ff70f 100644 (file)
@@ -1332,7 +1332,7 @@ void imap_cmd_finish(struct ImapData *idata)
       /* check_status: curs_main uses imap_check_mailbox to detect
        *   whether the index needs updating */
       idata->check_status = IMAP_NEWMAIL_PENDING;
-      imap_read_headers(idata, idata->max_msn + 1, count);
+      imap_read_headers(idata, idata->max_msn + 1, count, 0);
     }
     else if (idata->reopen & IMAP_EXPUNGE_PENDING)
     {
index 0a4d4dc89ca70223549b6c276a425d6e2b1ba8d2..05663d0974cb1958bd7aa2bcd221b4bfa99b30d5 100644 (file)
@@ -2224,7 +2224,7 @@ static int imap_mbox_open(struct Context *ctx)
   ctx->v2r = mutt_mem_calloc(count, sizeof(int));
   ctx->msgcount = 0;
 
-  if (count && (imap_read_headers(idata, 1, count) < 0))
+  if (count && (imap_read_headers(idata, 1, count, 1) < 0))
   {
     mutt_error(_("Error opening mailbox"));
     goto fail;
index 90e51381ccc2c603c2164b2bf689a9f496058b73..126eb92e4fa4d90e07e7fa29ece4aa0f76c251e3 100644 (file)
@@ -314,7 +314,8 @@ int imap_cmd_idle(struct ImapData *idata);
 
 /* message.c */
 void imap_free_header_data(struct ImapHeaderData **data);
-int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned int msn_end);
+int imap_read_headers (struct ImapData* idata, unsigned int msn_begin, unsigned int msn_end,
+                       int initial_download);
 char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *server_changes);
 int imap_cache_del(struct ImapData *idata, struct Header *h);
 int imap_cache_clean(struct ImapData *idata);
index 97db6d1c7db5f3f6a0f806daaade20822c5f1ebc..97a3a11114fcd35030da476ad9d1623f35c6ff8a 100644 (file)
@@ -1092,7 +1092,8 @@ bail:
  * the last message read. It will return a value other than msn_end if mail
  * comes in while downloading headers (in theory).
  */
-int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned int msn_end)
+int imap_read_headers(struct ImapData *idata, unsigned int msn_begin,
+                      unsigned int msn_end, int initial_download)
 {
   struct ImapStatus *status = NULL;
   int oldmsgcount;
@@ -1128,7 +1129,7 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned i
 #ifdef USE_HCACHE
   idata->hcache = imap_hcache_open(idata, NULL);
 
-  if (idata->hcache && (msn_begin == 1))
+  if (idata->hcache && initial_download)
   {
     uid_validity = mutt_hcache_fetch_raw(idata->hcache, "/UIDVALIDITY", 12);
     puidnext = mutt_hcache_fetch_raw(idata->hcache, "/UIDNEXT", 8);
@@ -1223,16 +1224,24 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned i
     mutt_hcache_store_raw(idata->hcache, "/UIDNEXT", 8, &idata->uidnext,
                           sizeof(idata->uidnext));
 
-  if (has_condstore || has_qresync)
-    mutt_hcache_store_raw(idata->hcache, "/MODSEQ", 7, &idata->modseq,
-                          sizeof(idata->modseq));
-  else
-    mutt_hcache_delete(idata->hcache, "/MODSEQ", 7);
+  /* We currently only sync CONDSTORE and QRESYNC on the initial download.
+   * To do it more often, we'll need to deal with flag updates combined with
+   * unsync'ed local flag changes.  We'll also need to properly sync flags to
+   * the header cache on close.  I'm not sure it's worth the added complexity.
+   */
+  if (initial_download)
+  {
+    if (has_condstore || has_qresync)
+      mutt_hcache_store_raw(idata->hcache, "/MODSEQ", 7, &idata->modseq,
+                            sizeof(idata->modseq));
+    else
+      mutt_hcache_delete(idata->hcache, "/MODSEQ", 7);
 
-  if (has_qresync)
-    imap_hcache_store_uid_seqset(idata);
-  else
-    imap_hcache_clear_uid_seqset(idata);
+    if (has_qresync)
+      imap_hcache_store_uid_seqset(idata);
+    else
+      imap_hcache_clear_uid_seqset(idata);
+  }
 #endif /* USE_HCACHE */
 
   if (ctx->msgcount > oldmsgcount)