dovecot-2.2: doveadm fts rescan: For virtual namespaces just mar...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 16 12:24:02 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/8c2cb7d01a78
changeset: 17816:8c2cb7d01a78
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 16 15:23:51 2014 +0300
description:
doveadm fts rescan: For virtual namespaces just mark the last indexed UID to 0.
diffstat:
src/plugins/fts-solr/fts-backend-solr.c | 24 +-----------------------
src/plugins/fts/fts-api-private.h | 1 +
src/plugins/fts/fts-api.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 23 deletions(-)
diffs (99 lines):
diff -r e82ad7f1c58f -r 8c2cb7d01a78 src/plugins/fts-solr/fts-backend-solr.c
--- a/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 16 14:32:20 2014 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr.c Tue Sep 16 15:23:51 2014 +0300
@@ -581,31 +581,9 @@
static int fts_backend_solr_rescan(struct fts_backend *backend)
{
- struct mailbox_list_iterate_context *iter;
- const struct mailbox_info *info;
- struct mailbox *box;
- int ret = 0;
-
/* FIXME: proper rescan needed. for now we'll just reset the
last-uids */
- iter = mailbox_list_iter_init(backend->ns->list, "*",
- MAILBOX_LIST_ITER_SKIP_ALIASES |
- MAILBOX_LIST_ITER_NO_AUTO_BOXES);
- while ((info = mailbox_list_iter_next(iter)) != NULL) {
- if ((info->flags &
- (MAILBOX_NONEXISTENT | MAILBOX_NOSELECT)) != 0)
- continue;
-
- box = mailbox_alloc(info->ns->list, info->vname, 0);
- if (mailbox_open(box) == 0) {
- if (fts_index_set_last_uid(box, 0) < 0)
- ret = -1;
- }
- mailbox_free(&box);
- }
- if (mailbox_list_iter_deinit(&iter) < 0)
- ret = -1;
- return ret;
+ return fts_backend_reset_last_uids(backend);
}
static int fts_backend_solr_optimize(struct fts_backend *backend ATTR_UNUSED)
diff -r e82ad7f1c58f -r 8c2cb7d01a78 src/plugins/fts/fts-api-private.h
--- a/src/plugins/fts/fts-api-private.h Tue Sep 16 14:32:20 2014 +0300
+++ b/src/plugins/fts/fts-api-private.h Tue Sep 16 15:23:51 2014 +0300
@@ -110,6 +110,7 @@
const struct fts_index_header *hdr);
int ATTR_NOWARN_UNUSED_RESULT
fts_index_set_last_uid(struct mailbox *box, uint32_t last_uid);
+int fts_backend_reset_last_uids(struct fts_backend *backend);
int fts_index_have_compatible_settings(struct mailbox_list *list,
uint32_t checksum);
diff -r e82ad7f1c58f -r 8c2cb7d01a78 src/plugins/fts/fts-api.c
--- a/src/plugins/fts/fts-api.c Tue Sep 16 14:32:20 2014 +0300
+++ b/src/plugins/fts/fts-api.c Tue Sep 16 15:23:51 2014 +0300
@@ -6,6 +6,7 @@
#include "mail-index.h"
#include "mail-namespace.h"
#include "mail-storage-private.h"
+#include "mailbox-list-iter.h"
#include "mail-search.h"
#include "../virtual/virtual-storage.h"
#include "fts-api-private.h"
@@ -198,8 +199,40 @@
return backend->v.refresh(backend);
}
+int fts_backend_reset_last_uids(struct fts_backend *backend)
+{
+ struct mailbox_list_iterate_context *iter;
+ const struct mailbox_info *info;
+ struct mailbox *box;
+ int ret = 0;
+
+ iter = mailbox_list_iter_init(backend->ns->list, "*",
+ MAILBOX_LIST_ITER_SKIP_ALIASES |
+ MAILBOX_LIST_ITER_NO_AUTO_BOXES);
+ while ((info = mailbox_list_iter_next(iter)) != NULL) {
+ if ((info->flags &
+ (MAILBOX_NONEXISTENT | MAILBOX_NOSELECT)) != 0)
+ continue;
+
+ box = mailbox_alloc(info->ns->list, info->vname, 0);
+ if (mailbox_open(box) == 0) {
+ if (fts_index_set_last_uid(box, 0) < 0)
+ ret = -1;
+ }
+ mailbox_free(&box);
+ }
+ if (mailbox_list_iter_deinit(&iter) < 0)
+ ret = -1;
+ return ret;
+}
+
int fts_backend_rescan(struct fts_backend *backend)
{
+ if (strcmp(backend->ns->storage->name, VIRTUAL_STORAGE_NAME) == 0) {
+ /* just reset the last-uids for a virtual storage. */
+ return fts_backend_reset_last_uids(backend);
+ }
+
return backend->v.rescan == NULL ? 0 :
backend->v.rescan(backend);
}
More information about the dovecot-cvs
mailing list