dovecot-2.2: lib-storage: Notify about \Seen flag changes in pri...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 28 07:25:28 EET 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/e123e31de340
changeset: 15429:e123e31de340
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 28 07:25:18 2012 +0200
description:
lib-storage: Notify about \Seen flag changes in private index.
Some earlier "don't send unnecessary flag changes" optimizations caused
this.
diffstat:
src/lib-storage/index/index-sync-private.h | 4 +++-
src/lib-storage/index/index-sync-pvt.c | 27 ++++++++++++++++++++++++---
src/lib-storage/index/index-sync.c | 18 ++++++++++++------
3 files changed, 39 insertions(+), 10 deletions(-)
diffs (102 lines):
diff -r 9107b794b7ad -r e123e31de340 src/lib-storage/index/index-sync-private.h
--- a/src/lib-storage/index/index-sync-private.h Wed Nov 28 07:24:01 2012 +0200
+++ b/src/lib-storage/index/index-sync-private.h Wed Nov 28 07:25:18 2012 +0200
@@ -22,6 +22,8 @@
void index_sync_search_results_update(struct index_mailbox_sync_context *ctx);
void index_sync_search_results_expunge(struct index_mailbox_sync_context *ctx);
-int index_storage_mailbox_sync_pvt(struct mailbox *box);
+int index_storage_mailbox_sync_pvt(struct mailbox *box,
+ ARRAY_TYPE(seq_range) *flag_updates,
+ ARRAY_TYPE(seq_range) *hidden_updates);
#endif
diff -r 9107b794b7ad -r e123e31de340 src/lib-storage/index/index-sync-pvt.c
--- a/src/lib-storage/index/index-sync-pvt.c Wed Nov 28 07:24:01 2012 +0200
+++ b/src/lib-storage/index/index-sync-pvt.c Wed Nov 28 07:25:18 2012 +0200
@@ -201,9 +201,13 @@
return ret;
}
-int index_storage_mailbox_sync_pvt(struct mailbox *box)
+int index_storage_mailbox_sync_pvt(struct mailbox *box,
+ ARRAY_TYPE(seq_range) *flag_updates,
+ ARRAY_TYPE(seq_range) *hidden_updates)
{
struct mail_index_view_sync_ctx *view_sync_ctx;
+ struct mail_index_view_sync_rec sync_rec;
+ uint32_t seq1, seq2;
enum mail_flags pvt_flags;
bool delayed_expunges;
int ret;
@@ -220,8 +224,25 @@
return -1;
/* sync the private view */
- view_sync_ctx = mail_index_view_sync_begin(box->view_pvt,
- MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
+ view_sync_ctx = mail_index_view_sync_begin(box->view_pvt, 0);
+ while (mail_index_view_sync_next(view_sync_ctx, &sync_rec)) {
+ if (sync_rec.type != MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS)
+ continue;
+
+ /* *_updates contains box->view sequences (not view_pvt
+ sequences) */
+ if (mail_index_lookup_seq_range(box->view,
+ sync_rec.uid1, sync_rec.uid2,
+ &seq1, &seq2)) {
+ if (!sync_rec.hidden) {
+ seq_range_array_add_range(flag_updates,
+ seq1, seq2);
+ } else {
+ seq_range_array_add_range(hidden_updates,
+ seq1, seq2);
+ }
+ }
+ }
if (mail_index_view_sync_commit(&view_sync_ctx, &delayed_expunges) < 0)
return -1;
return 0;
diff -r 9107b794b7ad -r e123e31de340 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Wed Nov 28 07:24:01 2012 +0200
+++ b/src/lib-storage/index/index-sync.c Wed Nov 28 07:25:18 2012 +0200
@@ -162,7 +162,11 @@
break;
}
}
+}
+static void
+index_view_sync_cleanup_updates(struct index_mailbox_sync_context *ctx)
+{
/* remove expunged messages from flag updates */
if (ctx->expunges != NULL) {
seq_range_array_remove_seq_range(&ctx->flag_updates,
@@ -210,6 +214,14 @@
}
index_view_sync_recs_get(ctx);
index_sync_search_results_expunge(ctx);
+
+ /* sync private index if needed. it doesn't use box->view, so it
+ doesn't matter if it's called at _sync_init() or _sync_deinit().
+ however we also need to know if any private flags have changed
+ since last sync, so we need to call it before _sync_next() calls. */
+ (void)index_storage_mailbox_sync_pvt(box, &ctx->flag_updates,
+ &ctx->hidden_updates);
+ index_view_sync_cleanup_updates(ctx);
return &ctx->ctx;
}
@@ -384,12 +396,6 @@
if (status_r != NULL)
status_r->sync_delayed_expunges = delayed_expunges;
- /* sync private index if needed. do this after real sync to make sure
- that all the new messages are added to the private index, so their
- flags can be updated. */
- if (ret == 0)
- (void)index_storage_mailbox_sync_pvt(_ctx->box);
-
/* update search results after private index is updated */
index_sync_search_results_update(ctx);
More information about the dovecot-cvs
mailing list