From: Marco Bettini Date: Wed, 26 Jul 2023 12:39:29 +0000 (+0000) Subject: indexer: Handle virtual folders in the indexer itself X-Git-Tag: 2.4.0~2536 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1be7f323f309f695bc4289746f89670f0e4d3ff;p=thirdparty%2Fdovecot%2Fcore.git indexer: Handle virtual folders in the indexer itself (rather than relying on code elsewhere to enumerate the backends of the virtual folder) --- diff --git a/src/indexer/master-connection.c b/src/indexer/master-connection.c index 53c8a4571b..f5e0c2c0af 100644 --- a/src/indexer/master-connection.c +++ b/src/indexer/master-connection.c @@ -64,7 +64,7 @@ get_attempt_error(unsigned int counter, uint32_t first_uid, uint32_t last_uid) } static int -index_mailbox_precache(struct master_connection *conn, struct mailbox *box) +index_mailbox_precache_real(struct master_connection *conn, struct mailbox *box) { struct mail_storage *storage = mailbox_get_storage(box); const char *username = mail_storage_get_user(storage)->username; @@ -184,6 +184,29 @@ index_mailbox_precache(struct master_connection *conn, struct mailbox *box) return ret; } +static int +index_mailbox_precache_virtual(struct master_connection *conn, 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 (index_mailbox_precache_real(conn, bbox) < 0) + return -1; + + return 0; +} + +static int +index_mailbox_precache(struct master_connection *conn, struct mailbox *box) +{ + return box->virtual_vfuncs == NULL ? + index_mailbox_precache_real(conn, box) : + index_mailbox_precache_virtual(conn, box); +} + static int index_mailbox(struct master_connection *conn, struct mail_user *user, const char *mailbox, unsigned int max_recent_msgs,