]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: storage - Use fts_settings for enforced
authorMarco Bettini <marco.bettini@open-xchange.com>
Fri, 1 Dec 2023 10:31:48 +0000 (10:31 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
src/plugins/fts/fts-storage.c
src/plugins/fts/fts-storage.h

index 625cd5ae99f8695024a5b176f07fc9246f0f1813..0f6894a2dac7ca0218c64dadf7b4a8854043ec67 100644 (file)
@@ -162,16 +162,6 @@ static bool fts_want_build_args(const struct mail_search_arg *args)
        return FALSE;
 }
 
-static enum fts_enforced fts_enforced_parse(const char *str)
-{
-       if (str == NULL || strcmp(str, "no") == 0)
-               return FTS_ENFORCED_NO;
-       else if (strcmp(str, "body") == 0)
-               return FTS_ENFORCED_BODY;
-       else
-               return FTS_ENFORCED_YES;
-}
-
 static struct mail_search_context *
 fts_mailbox_search_init(struct mailbox_transaction_context *t,
                        struct mail_search_args *args,
@@ -203,8 +193,6 @@ fts_mailbox_search_init(struct mailbox_transaction_context *t,
                hash_table_create(&fctx->last_indexed_virtual_uids,
                                  default_pool, 0, str_hash, strcmp);
        }
-       fctx->enforced = fts_enforced_parse(
-               mail_user_plugin_getenv(t->box->storage->user, "fts_enforced"));
        i_array_init(&fctx->levels, 8);
        fctx->scores = i_new(struct fts_scores, 1);
        fctx->scores->refcount = 1;
@@ -218,7 +206,7 @@ fts_mailbox_search_init(struct mailbox_transaction_context *t,
        ft->scores = fctx->scores;
        ft->scores->refcount++;
 
-       if (fctx->enforced == FTS_ENFORCED_YES ||
+       if (fbox->set->parsed_enforced == FTS_ENFORCED_YES ||
            fts_want_build_args(args->args))
                fts_try_build_init(ctx, fctx);
        else
@@ -260,7 +248,8 @@ static bool
 fts_mailbox_search_next_nonblock(struct mail_search_context *ctx,
                                 struct mail **mail_r, bool *tryagain_r)
 {
-       struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(ctx->transaction->box);
+       struct mailbox *box = ctx->transaction->box;
+       struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(box);
        struct fts_search_context *fctx = FTS_CONTEXT(ctx);
 
        if (fctx != NULL && fctx->indexer_ctx != NULL) {
@@ -275,7 +264,7 @@ fts_mailbox_search_next_nonblock(struct mail_search_context *ctx,
                }
        }
        if (fctx != NULL && !fctx->fts_lookup_success &&
-           fctx->enforced != FTS_ENFORCED_NO)
+           fbox->set->parsed_enforced != FTS_ENFORCED_NO)
                return FALSE;
 
        return fbox->module_ctx.super.
@@ -415,7 +404,8 @@ static bool fts_mailbox_search_next_update_seq(struct mail_search_context *ctx)
 
 static int fts_mailbox_search_deinit(struct mail_search_context *ctx)
 {
-       struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(ctx->transaction->box);
+       struct mailbox *box = ctx->transaction->box;
+       struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(box);
        struct fts_transaction_context *ft = FTS_CONTEXT_REQUIRE(ctx->transaction);
        struct fts_search_context *fctx = FTS_CONTEXT(ctx);
        int ret = 0;
@@ -430,14 +420,14 @@ static int fts_mailbox_search_deinit(struct mail_search_context *ctx)
                if (fctx->indexing_timed_out || fctx->mailbox_failed)
                        ret = -1;
                else if (fctx->mailbox_failed) {
-                       mail_storage_set_internal_error(ctx->transaction->box->storage);
+                       mail_storage_set_internal_error(box->storage);
                        ret = -1;
                }
                else if (!fctx->fts_lookup_success &&
-                        fctx->enforced != FTS_ENFORCED_NO) {
+                        fbox->set->parsed_enforced != FTS_ENFORCED_NO) {
                        /* FTS lookup failed and we didn't want to fallback to
                           opening all the mails and searching manually */
-                       mail_storage_set_internal_error(ctx->transaction->box->storage);
+                       mail_storage_set_internal_error(box->storage);
                        ret = -1;
                }
 
index 2479ea11aa925e5612b8c6cde0c0beda657276ec..7be772e43e2351fdc5cc71144ea80ad2d7d9d304 100644 (file)
@@ -26,7 +26,6 @@ struct fts_search_context {
        struct mailbox_transaction_context *t;
        struct mail_search_args *args;
        enum fts_lookup_flags flags;
-       enum fts_enforced enforced;
 
        pool_t result_pool;
        ARRAY(struct fts_search_level) levels;