EXPORTED modseq_t mailbox_modseq_dirty(struct mailbox *mailbox)
{
    assert(mailbox_index_islocked(mailbox, 1));

    if (mailbox->silentchanges) {
        mailbox->modseq_dirty = 1;
        mailbox_index_dirty(mailbox);
        return mailbox->i.highestmodseq;
    }

    if (!mailbox->modseq_dirty) {
        mailbox->i.highestmodseq = mboxname_setmodseq(mailbox_name(mailbox),
                                   mailbox->i.highestmodseq,
                                   mailbox_mbtype(mailbox), /*flags*/0);
        mailbox->last_updated = time(0);
        mailbox->modseq_dirty = 1;
        mailbox_index_dirty(mailbox);
    }

    mailbox->i.highestmodseq++;

    return mailbox->i.highestmodseq;
}
EXPORTED modseq_t mailbox_modseq_dirty(struct mailbox *mailbox)
{
    assert(mailbox_index_islocked(mailbox, 1));

    if (mailbox->silentchanges) {
        mailbox->modseq_dirty = 1;
        mailbox_index_dirty(mailbox);
        return mailbox->i.highestmodseq;
    }

    if (!mailbox->modseq_dirty) {
        mailbox->i.highestmodseq = mboxname_setmodseq(mailbox_name(mailbox),
                                   mailbox->i.highestmodseq,
                                   mailbox_mbtype(mailbox),  0);
        mailbox->last_updated = time(0);
        mailbox->modseq_dirty = 1;
        mailbox_index_dirty(mailbox);
    }

    mailbox->i.highestmodseq++;

    return mailbox->i.highestmodseq;
}