]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-lucene: If lucene-indexes dir is unexpectedly lost, rescan when expunge log updat...
authorTimo Sirainen <tss@iki.fi>
Tue, 12 Aug 2014 09:39:46 +0000 (12:39 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 12 Aug 2014 09:39:46 +0000 (12:39 +0300)
This mainly fixes a repeating error about failing to open the expunge log.
It should happen only if dovecot.index thinks that the mailbox is indexed
while in reality the entire lucene-indexes directory doesn't exist.

src/plugins/fts-lucene/fts-backend-lucene.c

index 676b59aaec970fa439a44cca21437d1e986deb6e..df03bd0ea1a033358ed787c9a56bea8820175eee 100644 (file)
@@ -272,8 +272,18 @@ fts_backend_lucene_update_deinit(struct fts_backend_update_context *_ctx)
        }
 
        if (ctx->expunge_ctx != NULL) {
-               if (fts_expunge_log_append_commit(&ctx->expunge_ctx) < 0)
+               if (fts_expunge_log_append_commit(&ctx->expunge_ctx) < 0) {
+                       struct stat st;
+
+                       if (stat(backend->dir_path, &st) < 0 && errno == ENOENT) {
+                               /* lucene-indexes directory doesn't even exist,
+                                  so dovecot.index's last_index_uid is wrong.
+                                  rescan to update them. */
+                               (void)lucene_index_rescan(backend->index);
+                               ret = 0;
+                       }
                        ret = -1;
+               }
        }
 
        if (fts_backend_lucene_need_optimize(ctx)) {