diff options
author | Kevin McCarthy <kevin@8t8.us> | 2018-08-13 09:43:55 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2018-08-13 09:43:55 -0700 |
commit | fe455d5fbcc464f5c0b462b04bcacf6861d32298 (patch) | |
tree | 9675428bc41b1d032f84026edac742f78dcfd665 /imap/message.c | |
parent | 289e5c8e21d4f9db1f2cf73addb31d425fac05cd (diff) |
Only sync CONDSTORE and QRESYNC on the initial download.
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.
Diffstat (limited to 'imap/message.c')
-rw-r--r-- | imap/message.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/imap/message.c b/imap/message.c index dbddee4e..a42369f5 100644 --- a/imap/message.c +++ b/imap/message.c @@ -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) |