From: Timo Sirainen Date: Fri, 30 May 2003 01:53:07 +0000 (+0300) Subject: If we're asking only custom flags (eg. APPEND), don't do any mailbox syncing. X-Git-Tag: 1.1.alpha1~4579 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=155c8dc1655619a3036fd59b70663493213b711b;p=thirdparty%2Fdovecot%2Fcore.git If we're asking only custom flags (eg. APPEND), don't do any mailbox syncing. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-status.c b/src/lib-storage/index/index-status.c index b37fc65d19..91e10b8d18 100644 --- a/src/lib-storage/index/index-status.c +++ b/src/lib-storage/index/index-status.c @@ -5,6 +5,10 @@ #include "mail-index-util.h" #include "index-storage.h" +#define STATUS_MESSAGE_COUNTS \ + (STATUS_MESSAGES | STATUS_RECENT | STATUS_UIDNEXT | \ + STATUS_UIDVALIDITY | STATUS_UNSEEN | STATUS_FIRST_UNSEEN_SEQ) + static unsigned int get_first_unseen_seq(struct mail_index *index) { struct mail_index_header *hdr; @@ -82,22 +86,29 @@ int index_storage_get_status(struct mailbox *box, memset(status, 0, sizeof(struct mailbox_status)); - /* if we're doing STATUS for selected mailbox, we have to sync it - first or STATUS reply may give different data */ - if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK)) - return FALSE; + if ((items & STATUS_MESSAGE_COUNTS) != 0) { + /* if we're doing STATUS for selected mailbox, we have to sync + it first or STATUS reply may give different data */ + if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK)) + return FALSE; - if (!index_storage_sync_modifylog(ibox, FALSE)) { - (void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK); - return FALSE; + if (!index_storage_sync_modifylog(ibox, FALSE)) { + (void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK); + return FALSE; + } + } else { + if (!index_storage_lock(ibox, MAIL_LOCK_SHARED)) + return FALSE; } /* we can get most of the status items without any trouble */ hdr = mail_index_get_header(ibox->index); - status->messages = hdr->messages_count; - status->unseen = hdr->messages_count - hdr->seen_messages_count; - status->uidvalidity = hdr->uid_validity; - status->uidnext = hdr->next_uid; + if ((items & STATUS_MESSAGE_COUNTS) != 0) { + status->messages = hdr->messages_count; + status->unseen = hdr->messages_count - hdr->seen_messages_count; + status->uidvalidity = hdr->uid_validity; + status->uidnext = hdr->next_uid; + } status->diskspace_full = ibox->index->nodiskspace; if (items & STATUS_FIRST_UNSEEN_SEQ) {