From: Stephan Bosch Date: Tue, 8 Oct 2019 16:56:56 +0000 (+0200) Subject: plugins: fts-solr: Move solr_lookup_add_doc() from solr-connection.c to solr-response.c. X-Git-Tag: 2.3.10~158 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd9f4e4b1ca9aac4e9edd034d105a8c75fbf561e;p=thirdparty%2Fdovecot%2Fcore.git plugins: fts-solr: Move solr_lookup_add_doc() from solr-connection.c to solr-response.c. --- diff --git a/src/plugins/fts-solr/solr-connection.c b/src/plugins/fts-solr/solr-connection.c index c9cdde746e..f6d0639f16 100644 --- a/src/plugins/fts-solr/solr-connection.c +++ b/src/plugins/fts-solr/solr-connection.c @@ -126,44 +126,6 @@ void solr_connection_deinit(struct solr_connection **_conn) i_free(conn); } -static int solr_lookup_add_doc(struct solr_lookup_xml_context *ctx) -{ - struct fts_score_map *score; - struct solr_result *result; - const char *box_id; - - if (ctx->uid == 0) { - i_error("fts_solr: uid missing from inside doc"); - return -1; - } - - if (ctx->mailbox == NULL) { - /* looking up from a single mailbox only */ - box_id = ""; - } else if (ctx->uidvalidity != 0) { - /* old style lookup */ - string_t *str = t_str_new(64); - str_printfa(str, "%u\001", ctx->uidvalidity); - str_append(str, ctx->mailbox); - if (ctx->ns != NULL) - str_printfa(str, "\001%s", ctx->ns); - box_id = str_c(str); - } else { - /* new style lookup */ - box_id = ctx->mailbox; - } - result = solr_result_get(ctx, box_id); - - if (seq_range_array_add(&result->uids, ctx->uid)) { - /* duplicate result */ - } else if (ctx->score != 0) { - score = array_append_space(&result->scores); - score->uid = ctx->uid; - score->score = ctx->score; - } - return 0; -} - static void solr_lookup_xml_end(void *context, const char *name ATTR_UNUSED) { struct solr_lookup_xml_context *ctx = context; diff --git a/src/plugins/fts-solr/solr-response.c b/src/plugins/fts-solr/solr-response.c index da55cde26c..baec9f3963 100644 --- a/src/plugins/fts-solr/solr-response.c +++ b/src/plugins/fts-solr/solr-response.c @@ -148,3 +148,40 @@ solr_result_get(struct solr_lookup_xml_context *ctx, const char *box_id) return result; } +static int solr_lookup_add_doc(struct solr_lookup_xml_context *ctx) +{ + struct fts_score_map *score; + struct solr_result *result; + const char *box_id; + + if (ctx->uid == 0) { + i_error("fts_solr: uid missing from inside doc"); + return -1; + } + + if (ctx->mailbox == NULL) { + /* looking up from a single mailbox only */ + box_id = ""; + } else if (ctx->uidvalidity != 0) { + /* old style lookup */ + string_t *str = t_str_new(64); + str_printfa(str, "%u\001", ctx->uidvalidity); + str_append(str, ctx->mailbox); + if (ctx->ns != NULL) + str_printfa(str, "\001%s", ctx->ns); + box_id = str_c(str); + } else { + /* new style lookup */ + box_id = ctx->mailbox; + } + result = solr_result_get(ctx, box_id); + + if (seq_range_array_add(&result->uids, ctx->uid)) { + /* duplicate result */ + } else if (ctx->score != 0) { + score = array_append_space(&result->scores); + score->uid = ctx->uid; + score->score = ctx->score; + } + return 0; +}