fts-storage.c revision a5e89374cb2fb2cad575fee6c3b33a9487ab9b3a
/* Copyright (c) 2006-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "mail-search.h"
#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "../virtual/virtual-storage.h"
#include "fts-api-private.h"
#include "fts-build.h"
#include "fts-search-serialize.h"
#include "fts-plugin.h"
#include "fts-storage.h"
#include <stdlib.h>
#define FTS_CONTEXT(obj) \
#define FTS_MAIL_CONTEXT(obj) \
#define FTS_LIST_CONTEXT(obj) \
struct fts_mailbox_list {
struct fts_backend *backend;
};
struct fts_mailbox {
union mailbox_module_context module_ctx;
};
struct fts_transaction_context {
struct fts_scores *scores;
};
struct fts_mail {
union mail_module_context module_ctx;
char score[30];
};
{
}
}
struct fts_search_context *fctx)
{
/* this process is already building the indexes */
return FALSE;
}
case -1:
break;
case 0:
/* the index was up to date */
break;
case 1:
/* hide "searching" notifications while building index */
break;
}
return TRUE;
}
{
/* we want to update index only when searching from message body.
it's not worth the wait for searching only from headers, which
could be in cache file already */
case SEARCH_OR:
case SEARCH_SUB:
case SEARCH_INTHREAD:
return TRUE;
break;
case SEARCH_BODY:
case SEARCH_TEXT:
return TRUE;
default:
break;
}
}
return FALSE;
}
static struct mail_search_context *
struct mail_search_args *args,
const enum mail_sort_type *sort_program,
struct mailbox_header_lookup_ctx *wanted_headers)
{
struct mail_search_context *ctx;
struct fts_search_context *fctx;
return ctx;
fctx->t = t;
/* transaction contains the last search's scores. they can be
queried later with mail_get_special() */
else {
}
return ctx;
}
{
int ret;
return TRUE;
if (!fctx->build_initialized) {
/* we're still waiting for this process (but another command)
to finish building the indexes */
return FALSE;
}
/* this command is still building the indexes */
if (ret == 0)
return FALSE;
ret = -1;
if (ret > 0)
}
return TRUE;
}
static bool
{
if (!fts_mailbox_build_continue(ctx)) {
*tryagain_r = TRUE;
return FALSE;
}
}
static void
{
const struct fts_search_level *level;
continue;
*idx += 1;
}
}
{
unsigned int idx;
/* fts lookup not done for this search */
}
/* restore original [non]matches */
return FALSE;
/* we've not indexed this far */
return TRUE;
}
/* apply [non]matches based on the FTS lookup results */
idx = 0;
return TRUE;
}
{
/* the search was cancelled */
}
}
}
{
}
const char **value_r)
{
const struct fts_score_map *scores;
else {
}
return 0;
}
}
{
return;
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct fts_transaction_context *ft;
return t;
}
static void fts_transaction_rollback(struct mailbox_transaction_context *t)
{
}
static int
struct mail_transaction_commit_changes *changes_r)
{
}
enum mailbox_sync_type sync_type)
{
if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE) {
/* this sync is finished */
}
return;
}
/* FIXME: maildir workaround - we could get here
because we're building an index, which doesn't find
some mail and starts syncing the mailbox.. */
return;
}
}
}
{
struct fts_storage_build_context *build_ctx;
int ret = 0;
return ret;
}
if (fts_build_deinit(&build_ctx) < 0)
ret = -1;
return ret < 0 ? -1 : 0;
}
struct mailbox_sync_status *status_r)
{
bool precache, force_resync;
int ret = 0;
return -1;
if (force_resync) {
"FTS optimize for mailbox %s failed",
ret = -1;
}
}
if (precache) {
if (fts_update(box) < 0) {
"FTS index update for mailbox %s failed",
ret = -1;
}
}
return ret;
}
{
struct fts_mailbox *fbox;
return;
v->sync_deinit = fts_sync_deinit;
}
{
}
{
struct fts_backend *backend;
i_debug("fts: No fts setting - plugin disabled");
return;
}
if (*path == '\0') {
i_debug("fts: Indexes disabled for namespace '%s'",
}
return;
}
i_error("fts: Failed to initialize backend '%s': %s",
} else {
struct fts_mailbox_list *flist;
}
}
{
}