From: Kevin McCarthy Date: Mon, 10 Jun 2019 21:51:50 +0000 (-0700) Subject: Allow imap_cmd_finish() to both expunge and fetch new mail X-Git-Tag: 2019-10-25~160^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e4214097a0b1ddd1be5c7c71cc0f95376b38661;p=neomutt Allow imap_cmd_finish() to both expunge and fetch new mail Since commit dd327606 changed check_status setting to use bit operators, and imap_check_mailbox() can call imap_cmd_finish() twice, there is no reason to delay the processing of new mail until a second call. imap_read_headers() deals with msn_end < msg_begin, so remove the (count > idata->max_msn) check. This will allow the reopen flag to be reset if somehow it's not the case. Co-authored-by: Richard Russon --- diff --git a/imap/command.c b/imap/command.c index c9a1172db..6876084f1 100644 --- a/imap/command.c +++ b/imap/command.c @@ -1286,10 +1286,11 @@ int imap_exec(struct ImapAccountData *adata, const char *cmdstr, ImapCmdFlags fl * imap_cmd_finish - Attempt to perform cleanup * @param adata Imap Account data * - * Attempts to perform cleanup (eg fetch new mail if detected, do expunge). - * Called automatically by imap_cmd_step(), but may be called at any time. - * Called by imap_check_mailbox() just before the index is refreshed, for - * instance. + * If a reopen is allowed, it attempts to perform cleanup (eg fetch new mail if + * detected, do expunge). Called automatically by imap_cmd_step(), but may be + * called at any time. + * + * mdata->check_status is set and will be used later by imap_check_mailbox(). */ void imap_cmd_finish(struct ImapAccountData *adata) { @@ -1320,6 +1321,10 @@ void imap_cmd_finish(struct ImapAccountData *adata) { mutt_debug(LL_DEBUG2, "Expunging mailbox\n"); imap_expunge_mailbox(adata->mailbox); + /* Detect whether we've gotten unexpected EXPUNGE messages */ + if (!(mdata->reopen & IMAP_EXPUNGE_EXPECTED)) + mdata->check_status |= IMAP_EXPUNGE_PENDING; + mdata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_EXPUNGE_EXPECTED); } // Then add new emails to it