doveadm-mail-index.c revision 6a262c9bd8f57cf1e57112e0522dbdab28ae8c29
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2010-2015 Dovecot authors, see the included COPYING file */
530b5909a99e7575156496f1b8e4d1ff5b058484Timo Sirainen#define INDEXER_HANDSHAKE "VERSION\tindexer\t1\t0\n"
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainenstatic int cmd_index_box_precache(struct mailbox *box)
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (mailbox_get_metadata(box, MAILBOX_METADATA_PRECACHE_FIELDS,
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen i_error("Mailbox %s: Precache-fields lookup failed: %s",
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_LAST_CACHED_SEQ,
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen i_error("Mailbox %s: Status lookup failed: %s",
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mailbox_get_vname(box), seq, status.messages);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen trans = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mail_search_build_add_seqset(search_args, seq, status.messages);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen ctx = mailbox_search_init(trans, search_args, NULL,
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (doveadm_verbose && ++counter % 100 == 0) {
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen i_error("Mailbox %s: Transaction commit failed: %s",
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen mailbox_get_vname(box), mailbox_get_last_error(box, NULL));
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainencmd_index_box(struct index_cmd_context *ctx, const struct mailbox_info *info)
009217abb57a24a4076092e8e4e165545747839eStephan Bosch box = mailbox_alloc(info->ns->list, info->vname,
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen /* index only if there aren't too many recent messages.
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen don't bother syncing the mailbox, that alone can take a
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen while with large maildirs. */
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen i_error("Opening mailbox %s failed: %s", info->vname,
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen mail_storage_get_last_error(mailbox_get_storage(box), NULL));
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen mailbox_get_open_status(box, STATUS_RECENT, &status);
009217abb57a24a4076092e8e4e165545747839eStephan Bosch if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen i_error("Syncing mailbox %s failed: %s", info->vname,
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen mail_storage_get_last_error(mailbox_get_storage(box), NULL));
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainenstatic void index_queue_connect(struct index_cmd_context *ctx)
6a33ecc05e60b511c1ae176ef113546e1012c18fTimo Sirainen path = t_strconcat(doveadm_settings->base_dir,
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen i_fatal("net_connect_unix(%s) failed: %m", path);
1c633f71ec2060e5bfa500a97f34cd881a958ecdTimo Sirainen if (write_full(ctx->queue_fd, INDEXER_HANDSHAKE,
250a06cde50c4004ac1cc72279b75a229a7f90f5Timo Sirainenstatic void cmd_index_queue(struct index_cmd_context *ctx,
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomi if (write_full(ctx->queue_fd, str_data(str), str_len(str)) < 0)
a23210844b06c53ebca34b162f3a268d5f1cd4d1Aki Tuomicmd_index_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
int ret = 0;
} T_END;
return ret;
const char *const args[])
return FALSE;
return TRUE;