]> granicus.if.org Git - mutt/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)
committerKevin McCarthy <kevin@8t8.us>
Mon, 13 Aug 2018 16:43:55 +0000 (09:43 -0700)
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 8e0ed562f7977a2e295205c123c52a1e4469f03c..ebfeaccf5979427c015524f704b5c1ca082d9bcc 100644 (file)
@@ -315,7 +315,7 @@ void imap_cmd_finish (IMAP_DATA* 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 fce5622d642265dc5427de50d88c9ccea683694c..f1997ac8b13757b5264b0578053be900d658f999 100644 (file)
@@ -817,7 +817,7 @@ static int imap_open_mailbox (CONTEXT* ctx)
   ctx->v2r = safe_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");
     mutt_sleep (1);
index d13a2c58c04d6a8c047df6b5edfdc9f7f5a19fad..d1b9ff42dde88326f6eeb0d65c302d002e109e1e 100644 (file)
@@ -285,7 +285,8 @@ int imap_cmd_idle (IMAP_DATA* idata);
 /* message.c */
 void imap_add_keywords (char* s, HEADER* keywords, LIST* mailbox_flags, size_t slen);
 void imap_free_header_data (IMAP_HEADER_DATA** data);
-int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int msn_end);
+int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int msn_end,
+                       int initial_download);
 char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s, int *server_changes);
 int imap_cache_del (IMAP_DATA* idata, HEADER* h);
 int imap_cache_clean (IMAP_DATA* idata);
index dbddee4ea218c48b7e6527715ebfeccaf93fa90e..a42369f52dd8081535effdbb5b5e86aeac1fb2f1 100644 (file)
@@ -173,7 +173,8 @@ static void imap_fetch_msn_seqset (BUFFER *b, IMAP_DATA *idata, unsigned int msn
  * msn of 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 (IMAP_DATA* idata, unsigned int msn_begin, unsigned int msn_end)
+int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int msn_end,
+                       int initial_download)
 {
   CONTEXT* ctx;
   IMAP_STATUS* status;
@@ -210,7 +211,7 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms
 #if 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", imap_hcache_keylen);
     puidnext = mutt_hcache_fetch_raw (idata->hcache, "/UIDNEXT", imap_hcache_keylen);
@@ -306,16 +307,24 @@ int imap_read_headers (IMAP_DATA* idata, unsigned int msn_begin, unsigned int ms
     mutt_hcache_store_raw (idata->hcache, "/UIDNEXT", &idata->uidnext,
                           sizeof (idata->uidnext), imap_hcache_keylen);
 
-  if (has_condstore || has_qresync)
-    mutt_hcache_store_raw (idata->hcache, "/MODSEQ", &idata->modseq,
-                           sizeof (idata->modseq), imap_hcache_keylen);
-  else
-    mutt_hcache_delete (idata->hcache, "/MODSEQ", imap_hcache_keylen);
+  /* 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", &idata->modseq,
+                             sizeof (idata->modseq), imap_hcache_keylen);
+    else
+      mutt_hcache_delete (idata->hcache, "/MODSEQ", imap_hcache_keylen);
 
-  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)