From: Mehdi Abaakouk Date: Wed, 21 Nov 2018 17:59:35 +0000 (+0100) Subject: Don't open the same mailbox twice X-Git-Tag: 2019-10-25~498 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2e5d9b474535b095fb2b5e40989898e13035b79;p=neomutt Don't open the same mailbox twice --- diff --git a/mailbox.h b/mailbox.h index d5b3fe896..9b074f491 100644 --- a/mailbox.h +++ b/mailbox.h @@ -124,6 +124,7 @@ struct Mailbox struct Hash *label_hash; /**< hash table for x-labels */ struct Account *account; + int opened; /**< number of times mailbox is opened */ int flags; /**< e.g. #MB_NORMAL */ diff --git a/mx.c b/mx.c index b37578273..2e1477f09 100644 --- a/mx.c +++ b/mx.c @@ -231,7 +231,9 @@ static int mx_open_mailbox_append(struct Mailbox *m, int flags) if (!m->mx_ops || !m->mx_ops->mbox_open_append) return -1; - return m->mx_ops->mbox_open_append(m, flags); + int rc = m->mx_ops->mbox_open_append(m, flags); + m->opened++; + return rc; } /** @@ -363,6 +365,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags) mutt_message(_("Reading %s..."), m->path); int rc = m->mx_ops->mbox_open(ctx); + m->opened++; if ((rc == 0) || (rc == -2)) { @@ -400,6 +403,10 @@ void mx_fastclose_mailbox(struct Context *ctx) struct Mailbox *m = ctx->mailbox; + m->opened--; + if (m->opened != 0) + return; + /* never announce that a mailbox we've just left has new mail. #3290 * TODO: really belongs in mx_mbox_close, but this is a nice hook point */ if (!m->peekonly)