/* 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)
{
/* 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);
* 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;
#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);
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)