From: Richard Russon Date: Thu, 12 Sep 2019 17:05:57 +0000 (+0100) Subject: fix mbox's handling of new mail X-Git-Tag: 2019-10-25~24^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bcd7bc3b014eb155c53c149c114ad40d97e52b34;p=neomutt fix mbox's handling of new mail `Mailbox.has_new` is tied to the timestamp of an mbox, not its count of new mail. Visiting a Mailbox will clear the flag, touch(1) the file. Whether the new emails get changed to old emails depends on $mark_old. --- diff --git a/mbox/mbox.c b/mbox/mbox.c index 49a90017e..a1472e701 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1495,7 +1495,7 @@ static int mbox_mbox_close(struct Mailbox *m) mutt_file_fclose(&adata->fp); /* fix up the times so mailbox won't get confused */ - if (m->peekonly && mutt_buffer_is_empty(&m->pathbuf) && + if (m->peekonly && !mutt_buffer_is_empty(&m->pathbuf) && (mutt_file_timespec_compare(&m->mtime, &adata->atime) > 0)) { #ifdef HAVE_UTIMENSAT @@ -1768,7 +1768,7 @@ static int mbox_mbox_check_stats(struct Mailbox *m, int flags) if (m->newly_created && ((sb.st_ctime != sb.st_mtime) || (sb.st_ctime != sb.st_atime))) m->newly_created = false; - if (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->stats_last_checked) > 0) + if (flags && mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->stats_last_checked) > 0) { struct Context *ctx = mx_mbox_open(m, MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK); if (ctx) @@ -1781,6 +1781,9 @@ static int mbox_mbox_check_stats(struct Mailbox *m, int flags) } } + if (m->msg_new == 0) + m->has_new = false; + return (m->msg_new > 0); } diff --git a/mutt_mailbox.c b/mutt_mailbox.c index 6cb89b79b..fa904a679 100644 --- a/mutt_mailbox.c +++ b/mutt_mailbox.c @@ -56,7 +56,8 @@ static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, m_check->magic = mb_magic; break; default: - m_check->has_new = false; + if (m_cur == m_check) + m_check->has_new = false; if ((stat(mailbox_path(m_check), &sb) != 0) || (S_ISREG(sb.st_mode) && (sb.st_size == 0)) || diff --git a/mx.c b/mx.c index 53ce97851..86ed93637 100644 --- a/mx.c +++ b/mx.c @@ -303,12 +303,10 @@ struct Context *mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags) m->msg_flagged = 0; m->rights = MUTT_ACL_ALL; - if (flags & MUTT_QUIET) - m->quiet = true; + m->quiet = (flags & MUTT_QUIET); if (flags & MUTT_READONLY) m->readonly = true; - if (flags & MUTT_PEEK) - m->peekonly = true; + m->peekonly = (flags & MUTT_PEEK); if (flags & (MUTT_APPEND | MUTT_NEWFOLDER)) {