Mercurial > dovecot > core-2.2
changeset 18523:eee937dc9438
fts: Initialize fts backend in mail_namespaces_added(), not in mailbox_list_created()
This way the storage has already been created by the time fts initialization
starts, which simplifies things.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 05 May 2015 16:17:14 +0300 |
parents | 164d4d499069 |
children | 25f29613908f |
files | src/plugins/fts/fts-plugin.c src/plugins/fts/fts-storage.c src/plugins/fts/fts-storage.h |
diffstat | 3 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/fts/fts-plugin.c Tue May 05 16:14:07 2015 +0300 +++ b/src/plugins/fts/fts-plugin.c Tue May 05 16:17:14 2015 +0300 @@ -13,7 +13,7 @@ const char *fts_plugin_version = DOVECOT_ABI_VERSION; static struct mail_storage_hooks fts_mail_storage_hooks = { - .mailbox_list_created = fts_mailbox_list_created, + .mail_namespaces_added = fts_mail_namespaces_added, .mailbox_allocated = fts_mailbox_allocated, .mail_allocated = fts_mail_allocated };
--- a/src/plugins/fts/fts-storage.c Tue May 05 16:14:07 2015 +0300 +++ b/src/plugins/fts/fts-storage.c Tue May 05 16:17:14 2015 +0300 @@ -756,17 +756,11 @@ return 0; } -void fts_mailbox_list_created(struct mailbox_list *list) +static void +fts_mailbox_list_init(struct mailbox_list *list, const char *name) { struct fts_backend *backend; - const char *name, *path, *error; - - name = mail_user_plugin_getenv(list->ns->user, "fts"); - if (name == NULL) { - if (list->mail_set->mail_debug) - i_debug("fts: No fts setting - plugin disabled"); - return; - } + const char *path, *error; if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX, &path)) { if (list->mail_set->mail_debug) { @@ -797,6 +791,22 @@ } } +void fts_mail_namespaces_added(struct mail_namespace *namespaces) +{ + struct mail_namespace *ns; + const char *name; + + name = mail_user_plugin_getenv(namespaces->user, "fts"); + if (name == NULL) { + if (namespaces->user->mail_debug) + i_debug("fts: No fts setting - plugin disabled"); + return; + } + + for (ns = namespaces; ns != NULL; ns = ns->next) + fts_mailbox_list_init(ns->list, name); +} + struct fts_backend *fts_mailbox_backend(struct mailbox *box) { struct fts_mailbox_list *flist = FTS_LIST_CONTEXT(box->list);
--- a/src/plugins/fts/fts-storage.h Tue May 05 16:14:07 2015 +0300 +++ b/src/plugins/fts/fts-storage.h Tue May 05 16:17:14 2015 +0300 @@ -52,6 +52,6 @@ void fts_mail_allocated(struct mail *mail); void fts_mailbox_allocated(struct mailbox *box); -void fts_mailbox_list_created(struct mailbox_list *list); +void fts_mail_namespaces_added(struct mail_namespace *namespaces); #endif