From: Timo Sirainen Date: Wed, 10 Aug 2011 13:08:45 +0000 (+0300) Subject: doveadm index -n: Don't sync mailbox when checking the recent count. X-Git-Tag: 2.1.alpha1~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecf44c74416ffa4e7c331e49a1e283be6b1aa668;p=thirdparty%2Fdovecot%2Fcore.git doveadm index -n: Don't sync mailbox when checking the recent count. The syncing alone can take a long time with huge maildirs. Better to be slightly wrong than waste a lot of time all the time. --- diff --git a/src/doveadm/doveadm-mail-index.c b/src/doveadm/doveadm-mail-index.c index 7cc28bce32..35788b767b 100644 --- a/src/doveadm/doveadm-mail-index.c +++ b/src/doveadm/doveadm-mail-index.c @@ -34,11 +34,15 @@ cmd_index_box(struct index_cmd_context *ctx, const struct mailbox_info *info) MAILBOX_FLAG_KEEP_RECENT | MAILBOX_FLAG_IGNORE_ACLS); if (ctx->max_recent_msgs != 0) { - /* index only if there aren't too many recent messages */ - if (mailbox_get_status(box, STATUS_RECENT, &status) < 0) { - i_error("Mailbox %s status failed: %s", info->name, + /* index only if there aren't too many recent messages. + don't bother syncing the mailbox, that alone can take a + while with large maildirs. */ + if (mailbox_open(box) < 0) { + i_error("Opening mailbox %s failed: %s", info->name, mail_storage_get_last_error(mailbox_get_storage(box), NULL)); ret = -1; + } else { + mailbox_get_open_status(box, STATUS_RECENT, &status); } if (ret < 0 || status.recent > ctx->max_recent_msgs) { mailbox_free(&box); diff --git a/src/indexer/master-connection.c b/src/indexer/master-connection.c index c75118d912..947f586786 100644 --- a/src/indexer/master-connection.c +++ b/src/indexer/master-connection.c @@ -64,11 +64,15 @@ static int index_mailbox(struct mail_user *user, const char *mailbox, "n% competed" notifications */ box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_KEEP_RECENT); if (max_recent_msgs != 0) { - /* index only if there aren't too many recent messages */ - if (mailbox_get_status(box, STATUS_RECENT, &status) < 0) { - i_error("Mailbox %s status failed: %s", mailbox, + /* index only if there aren't too many recent messages. + don't bother syncing the mailbox, that alone can take a + while with large maildirs. */ + if (mailbox_open(box) < 0) { + i_error("Opening mailbox %s failed: %s", mailbox, mail_storage_get_last_error(mailbox_get_storage(box), NULL)); ret = -1; + } else { + mailbox_get_open_status(box, STATUS_RECENT, &status); } if (ret < 0 || status.recent > max_recent_msgs) { mailbox_free(&box);