]> granicus.if.org Git - neomutt/commitdiff
Allow imap_cmd_finish() to both expunge and fetch new mail
authorKevin McCarthy <kevin@8t8.us>
Mon, 10 Jun 2019 21:51:50 +0000 (14:51 -0700)
committerRichard Russon <rich@flatcap.org>
Sun, 16 Jun 2019 00:28:13 +0000 (01:28 +0100)
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 <rich@flatcap.org>
imap/command.c

index c9a1172dbf353fa89deb353b9d59262cb9eee283..6876084f13194bf8d68180dc070f3bc646c3abbb 100644 (file)
@@ -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