From: Marco Bettini Date: Wed, 25 Oct 2023 12:30:16 +0000 (+0000) Subject: doveadm index: Fix for fts crashing on virtual folders X-Git-Tag: 2.4.0~2482 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56988ce4108ec79db384c8f58747334257de8927;p=thirdparty%2Fdovecot%2Fcore.git doveadm index: Fix for fts crashing on virtual folders Broken by: d1be7f323f (implemented in indexer but not in doveadm) --- diff --git a/src/doveadm/doveadm-mail-index.c b/src/doveadm/doveadm-mail-index.c index dd75e04c96..03426c7940 100644 --- a/src/doveadm/doveadm-mail-index.c +++ b/src/doveadm/doveadm-mail-index.c @@ -7,7 +7,7 @@ #include "istream.h" #include "ostream.h" #include "mail-namespace.h" -#include "mail-storage.h" +#include "mail-storage-private.h" #include "mail-search-build.h" #include "mailbox-list-iter.h" #include "doveadm-settings.h" @@ -28,8 +28,8 @@ struct index_cmd_context { bool have_wildcards:1; }; -static int cmd_index_box_precache(struct doveadm_mail_cmd_context *dctx, - struct mailbox *box) +static int cmd_index_box_precache_real(struct doveadm_mail_cmd_context *dctx, + struct mailbox *box) { struct event *event = dctx->cctx->event; struct mailbox_status status; @@ -114,6 +114,31 @@ static int cmd_index_box_precache(struct doveadm_mail_cmd_context *dctx, return ret; } +static int cmd_index_box_precache(struct doveadm_mail_cmd_context *dctx, + struct mailbox *box); + +static int cmd_index_box_precache_virtual(struct doveadm_mail_cmd_context *dctx, + struct mailbox *box) +{ + ARRAY_TYPE(mailboxes) mailboxes; + t_array_init(&mailboxes, 8); + box->virtual_vfuncs->get_virtual_backend_boxes(box, &mailboxes, TRUE); + + struct mailbox *bbox; + array_foreach_elem(&mailboxes, bbox) + if (cmd_index_box_precache(dctx, bbox) < 0) + return -1; + return 0; +} + +static int cmd_index_box_precache(struct doveadm_mail_cmd_context *dctx, + struct mailbox *box) +{ + return box->virtual_vfuncs == NULL ? + cmd_index_box_precache_real(dctx, box) : + cmd_index_box_precache_virtual(dctx, box); +} + static int cmd_index_box(struct index_cmd_context *ctx, const struct mailbox_info *info) {