From: Kevin McCarthy Date: Wed, 5 Jun 2019 21:04:55 +0000 (-0700) Subject: Fix dropped new mail notifications when an EXPUNGE_PENDING is set. X-Git-Tag: mutt-1-12-1-rel~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3f66d7e;p=mutt Fix dropped new mail notifications when an EXPUNGE_PENDING is set. Prior to the fetch_headers rework and introduction of idata->max_msn (starting around e0376c75), cmd_handle_untagged() was looking directly at ctx->msgcount, which isn't fixed up until imap_expunge_mailbox(). At that time, more care had to be taken inbetween handling the EXPUNGE message and the actual expunge of the mailbox because of the discrepency between server state and mailbox context state. idata->max_msn is now decremented during the processing of EXPUNGE and VANISHED notices from the server, so reflect "current" state. So, when we receive an EXISTS notice, we no longer need the checks for expunge state and can always set the NEWMAIL_PENDING flag. Additionally, fix imap_cmd_finish() to retain the IMAP_NEWMAIL_PENDING flag after handling an expunge. The expunge does not grab new messages so dropping the flag would cause mutt to forget the new mail status until another EXISTS command. Since this is a stable branch fix, I'm leaving the either/or processing of expunge versus new mail in imap_cmd_finish(). However, I don't see why this has to be done in two calls. I may rework that in master to process an expunge and then the new mail one after the other. --- diff --git a/imap/command.c b/imap/command.c index a7b44712..82c373d5 100644 --- a/imap/command.c +++ b/imap/command.c @@ -327,8 +327,7 @@ void imap_cmd_finish (IMAP_DATA* idata) if ((idata->reopen & IMAP_EXPUNGE_PENDING) && !(idata->reopen & IMAP_EXPUNGE_EXPECTED)) idata->check_status = IMAP_EXPUNGE_PENDING; - idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_NEWMAIL_PENDING | - IMAP_EXPUNGE_EXPECTED); + idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_EXPUNGE_EXPECTED); } } @@ -521,8 +520,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata) /* new mail arrived */ mutt_atoui (pn, &count); - if ( !(idata->reopen & IMAP_EXPUNGE_PENDING) && - count < idata->max_msn) + if (count < idata->max_msn) { /* Notes 6.0.3 has a tendency to report fewer messages exist than * it should. */ @@ -536,13 +534,10 @@ static int cmd_handle_untagged (IMAP_DATA* idata) "cmd_handle_untagged: superfluous EXISTS message.\n")); else { - if (!(idata->reopen & IMAP_EXPUNGE_PENDING)) - { - dprint (2, (debugfile, - "cmd_handle_untagged: New mail in %s - %d messages total.\n", - idata->mailbox, count)); - idata->reopen |= IMAP_NEWMAIL_PENDING; - } + dprint (2, (debugfile, + "cmd_handle_untagged: New mail in %s - %d messages total.\n", + idata->mailbox, count)); + idata->reopen |= IMAP_NEWMAIL_PENDING; idata->newMailCount = count; } }