Mercurial > dovecot > core-2.2
changeset 21258:f50c3b9dfbba
lib-storage: Return vsize=0 from mailbox list index for empty mailboxes.
If it's known that the mailbox has no mails, there's no reason to open the
mailbox to see that its size is 0.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 01 Dec 2016 00:56:11 +0200 |
parents | a6395b1f1fad |
children | 5c75425daf63 |
files | src/lib-storage/list/mailbox-list-index-status.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index-status.c Wed Nov 30 15:59:01 2016 +0200 +++ b/src/lib-storage/list/mailbox-list-index-status.c Thu Dec 01 00:56:11 2016 +0200 @@ -264,8 +264,13 @@ ret = mailbox_list_index_status(box->list, view, seq, STATUS_MESSAGES | STATUS_UIDNEXT, &status, NULL, &vsize) ? 1 : 0; - if (ret > 0 && (vsize.highest_uid + 1 != status.uidnext || - vsize.message_count != status.messages)) { + if (status.messages == 0 && status.uidnext > 0) { + /* mailbox is empty. its size has to be zero, regardless of + what the vsize header says. */ + vsize.vsize = 0; + ret = 1; + } else if (ret > 0 && (vsize.highest_uid + 1 != status.uidnext || + vsize.message_count != status.messages)) { /* out of date vsize info */ ret = 0; }