]> granicus.if.org Git - mutt/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)
committerKevin McCarthy <kevin@8t8.us>
Tue, 11 Jun 2019 01:10:22 +0000 (18:10 -0700)
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.

imap/command.c

index d76ce200657f303c67c05445a19b6db1dda6b643..69ac0b02b37c91a4030c26573a6151ceb8316cd8 100644 (file)
@@ -289,10 +289,15 @@ int imap_exec (IMAP_DATA* idata, const char* cmdstr, int flags)
   return 0;
 }
 
-/* imap_cmd_finish: 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. */
+/* imap_cmd_finish
+ *
+ * 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.
+ *
+ * idata->check_status is set and will be used later by
+ * imap_check_mailbox().
+ */
 void imap_cmd_finish (IMAP_DATA* idata)
 {
   if (idata->status == IMAP_FATAL)
@@ -306,29 +311,21 @@ void imap_cmd_finish (IMAP_DATA* idata)
 
   if (idata->reopen & IMAP_REOPEN_ALLOW)
   {
-    unsigned int count = idata->newMailCount;
-
-    if (!(idata->reopen & IMAP_EXPUNGE_PENDING) &&
-       (idata->reopen & IMAP_NEWMAIL_PENDING)
-       && count > idata->max_msn)
-    {
-      /* read new mail messages */
-      dprint (2, (debugfile, "imap_cmd_finish: Fetching new mail\n"));
-      /* 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, 0);
-    }
-    else if (idata->reopen & IMAP_EXPUNGE_PENDING)
+    if (idata->reopen & IMAP_EXPUNGE_PENDING)
     {
       dprint (2, (debugfile, "imap_cmd_finish: Expunging mailbox\n"));
       imap_expunge_mailbox (idata);
       /* Detect whether we've gotten unexpected EXPUNGE messages */
-      if ((idata->reopen & IMAP_EXPUNGE_PENDING) &&
-         !(idata->reopen & IMAP_EXPUNGE_EXPECTED))
+      if (!(idata->reopen & IMAP_EXPUNGE_EXPECTED))
        idata->check_status |= IMAP_EXPUNGE_PENDING;
       idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_EXPUNGE_EXPECTED);
     }
+    if (idata->reopen & IMAP_NEWMAIL_PENDING)
+    {
+      dprint (2, (debugfile, "imap_cmd_finish: Fetching new mail\n"));
+      imap_read_headers (idata, idata->max_msn+1, idata->newMailCount, 0);
+      idata->check_status |= IMAP_NEWMAIL_PENDING;
+    }
   }
 
   idata->status = 0;