Change mbox_check_stats() to clearly show when a Mailbox has new mail.
Return:
* -1 Error
* 0 Success, no new mail
* 1 Success, some new mail
A bug was introduced when mbox_check_stats() was created that caused
'mbox' Mailboxes to always appear as if they had new mail.
{
int rc = imap_mailbox_status(m, true);
if (rc > 0)
- rc = 0;
+ rc = 1;
return rc;
}
if (check_new || check_stats)
maildir_check_dir(m, "cur", check_new, check_stats);
- return 0;
+ return (m->msg_new > 0);
}
/**
{
struct MhSequences mhs = { 0 };
bool check_new = true;
- bool rc = false;
+ int rc = -1;
DIR *dirp = NULL;
struct dirent *de = NULL;
* since the last m visit, there is no "new mail" */
if (C_MailCheckRecent && (mh_sequences_changed(m) <= 0))
{
- rc = false;
+ rc = 0;
check_new = false;
}
return 0;
if (mh_read_sequences(&mhs, mailbox_path(m)) < 0)
- return false;
+ return -1;
m->msg_count = 0;
m->msg_unread = 0;
if (!C_MailCheckRecent || (mh_already_notified(m, i) == 0))
{
m->has_new = true;
- rc = true;
+ rc = 1;
}
/* Because we are traversing from high to low, we can stop
* checking for new mail after the first unseen message.
}
}
- return 0;
+ return (m->msg_new > 0);
}
// clang-format off
case MUTT_MAILDIR:
case MUTT_MH:
case MUTT_NOTMUCH:
- if (mx_mbox_check_stats(m_check, 0) == 0)
+ if ((mx_mbox_check_stats(m_check, check_stats) == 1) && m_check->has_new)
MailboxCount++;
break;
default:; /* do nothing */
*/
bool mutt_mailbox_notify(struct Mailbox *m_cur)
{
- if (mutt_mailbox_check(m_cur, 0) && MailboxNotify)
+ if ((mutt_mailbox_check(m_cur, 0) > 0) && MailboxNotify)
{
return mutt_mailbox_list();
}
{
mutt_buffer_expand_path(s);
- if (mutt_mailbox_check(m_cur, 0))
+ if (mutt_mailbox_check(m_cur, 0) > 0)
{
bool found = false;
for (int pass = 0; pass < 2; pass++)
* mbox_check_stats - Check the Mailbox statistics
* @param m Mailbox to check
* @param flags Function flags
- * @retval 0 Success
+ * @retval 0 Success, no new mail
+ * @retval 1 Success, some new mail
* @retval -1 Failure
*/
int (*mbox_check_stats)(struct Mailbox *m, int flags);
m->msg_flagged = count_query(db, qstr, limit);
FREE(&qstr);
- rc = 0;
+ rc = (m->msg_new > 0);
done:
if (db)
{