]> granicus.if.org Git - neomutt/commitdiff
Enable the idata->check_status using bit operations
authorKevin McCarthy <kevin@8t8.us>
Thu, 6 Jun 2019 23:03:42 +0000 (16:03 -0700)
committerRichard Russon <rich@flatcap.org>
Fri, 7 Jun 2019 00:08:03 +0000 (01:08 +0100)
Commit e3f66d7e fixed dropped new mail notications, removing the
unsetting of idata->reopen IMAP_NEWMAIL_PENDING in imap_cmd_finish()
when an EXPUNGE was processed.

However, imap_cmd_finish() can be called twice by
imap_check_mailbox().  First as part of the imap_exec(), and manually
again just below.

Now that the IMAP_NEWMAIL_PENDING still exists, a second call could
overwrite idata->check_status if both reopen flags were set.

This unfortunately affects update_index(), which behaves differently
for MUTT_REOPENED.

I need to change the return value of mx_check_mailbox() in master to
preserve all the bits, so the index can both notify of new mail and
update_index() properly.

For stable, the best fix is to use bit operators to enable the
check_status flags in imap_cmd_finish() (and cmd_parse_fetch for
flags), and keep the imap_check_mailbox() priority of setting its
return value (it prioritizes IMAP_EXCHANGE_PENDING).

Co-authored-by: Richard Russon <rich@flatcap.org>
imap/command.c

index 6d5443dd6cbbac708c938c4f030be9a597cee407..ea85b28272f2624386ec0fb7177b5f0a148ea994 100644 (file)
@@ -508,7 +508,7 @@ static void cmd_parse_fetch(struct ImapAccountData *adata, char *s)
       if (e->changed)
         mdata->reopen |= IMAP_EXPUNGE_PENDING;
       else
-        mdata->check_status = IMAP_FLAGS_PENDING;
+        mdata->check_status |= IMAP_FLAGS_PENDING;
     }
   }
 }
@@ -1326,7 +1326,7 @@ void imap_cmd_finish(struct ImapAccountData *adata)
     if (mdata->reopen & IMAP_NEWMAIL_PENDING && (mdata->new_mail_count > mdata->max_msn))
     {
       if (!(mdata->reopen & IMAP_EXPUNGE_PENDING))
-        mdata->check_status = IMAP_NEWMAIL_PENDING;
+        mdata->check_status |= IMAP_NEWMAIL_PENDING;
 
       mutt_debug(LL_DEBUG2, "Fetching new mails from %d to %d\n",
                  mdata->max_msn + 1, mdata->new_mail_count);
@@ -1335,7 +1335,7 @@ void imap_cmd_finish(struct ImapAccountData *adata)
 
     // And to finish inform about MUTT_REOPEN if needed
     if (mdata->reopen & IMAP_EXPUNGE_PENDING && !(mdata->reopen & IMAP_EXPUNGE_EXPECTED))
-      mdata->check_status = IMAP_EXPUNGE_PENDING;
+      mdata->check_status |= IMAP_EXPUNGE_PENDING;
 
     if (mdata->reopen & IMAP_EXPUNGE_PENDING)
       mdata->reopen &=