]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
indexer: Handle virtual folders in the indexer itself
authorMarco Bettini <marco.bettini@open-xchange.com>
Wed, 26 Jul 2023 12:39:29 +0000 (12:39 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Tue, 10 Oct 2023 07:13:49 +0000 (07:13 +0000)
(rather than relying on code elsewhere to enumerate the
backends of the virtual folder)

src/indexer/master-connection.c

index 53c8a4571b46c18be344aa751cc46e3dcac1bdb1..f5e0c2c0aff6dfb670c3eacb47aa675a4cfb0333 100644 (file)
@@ -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,