]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm index -n: Don't sync mailbox when checking the recent count.
authorTimo Sirainen <tss@iki.fi>
Wed, 10 Aug 2011 13:08:45 +0000 (16:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 10 Aug 2011 13:08:45 +0000 (16:08 +0300)
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.

src/doveadm/doveadm-mail-index.c
src/indexer/master-connection.c

index 7cc28bce3213a87bf7d6826a7afeb25a781f2dfd..35788b767bef946339de14610a98d39547fc3d9a 100644 (file)
@@ -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);
index c75118d91272be01d247fb9c3d5225d60e2a8114..947f586786f9915783e99abfac4307eb51e676db 100644 (file)
@@ -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);