dovecot-2.2: lib-index: Added mail_index_sync_have_any_expunges()
dovecot at dovecot.org
dovecot at dovecot.org
Sun Sep 20 19:26:29 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/91f68c1b9b36
changeset: 19158:91f68c1b9b36
user: Timo Sirainen <tss at iki.fi>
date: Sun Sep 20 22:25:11 2015 +0300
description:
lib-index: Added mail_index_sync_have_any_expunges()
This can be used to quickly check before mail_index_sync_begin() if there
are likely to be any expunges that will be synced.
diffstat:
src/lib-index/mail-index-sync.c | 25 ++++++++++++++++++++-----
src/lib-index/mail-index.h | 2 ++
2 files changed, 22 insertions(+), 5 deletions(-)
diffs (71 lines):
diff -r d482a8097362 -r 91f68c1b9b36 src/lib-index/mail-index-sync.c
--- a/src/lib-index/mail-index-sync.c Sun Sep 20 21:49:51 2015 +0300
+++ b/src/lib-index/mail-index-sync.c Sun Sep 20 22:25:11 2015 +0300
@@ -526,7 +526,8 @@
}
static bool mail_index_sync_view_have_any(struct mail_index_view *view,
- enum mail_index_sync_flags flags)
+ enum mail_index_sync_flags flags,
+ bool expunges_only)
{
const struct mail_transaction_header *hdr;
const void *data;
@@ -560,19 +561,22 @@
continue;
switch (hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
+ case MAIL_TRANSACTION_EXPUNGE:
+ case MAIL_TRANSACTION_EXPUNGE_GUID:
+ return TRUE;
case MAIL_TRANSACTION_EXT_REC_UPDATE:
case MAIL_TRANSACTION_EXT_ATOMIC_INC:
/* extension record updates aren't exactly needed
to be synced, but cache syncing relies on tail
offsets being updated. */
- case MAIL_TRANSACTION_EXPUNGE:
- case MAIL_TRANSACTION_EXPUNGE_GUID:
case MAIL_TRANSACTION_FLAG_UPDATE:
case MAIL_TRANSACTION_KEYWORD_UPDATE:
case MAIL_TRANSACTION_KEYWORD_RESET:
case MAIL_TRANSACTION_INDEX_DELETED:
case MAIL_TRANSACTION_INDEX_UNDELETED:
- return TRUE;
+ if (!expunges_only)
+ return TRUE;
+ break;
default:
break;
}
@@ -587,7 +591,18 @@
bool ret;
view = mail_index_view_open(index);
- ret = mail_index_sync_view_have_any(view, flags);
+ ret = mail_index_sync_view_have_any(view, flags, FALSE);
+ mail_index_view_close(&view);
+ return ret;
+}
+
+bool mail_index_sync_have_any_expunges(struct mail_index *index)
+{
+ struct mail_index_view *view;
+ bool ret;
+
+ view = mail_index_view_open(index);
+ ret = mail_index_sync_view_have_any(view, 0, TRUE);
mail_index_view_close(&view);
return ret;
}
diff -r d482a8097362 -r 91f68c1b9b36 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h Sun Sep 20 21:49:51 2015 +0300
+++ b/src/lib-index/mail-index.h Sun Sep 20 22:25:11 2015 +0300
@@ -363,6 +363,8 @@
/* Returns TRUE if it currently looks like syncing would return changes. */
bool mail_index_sync_have_any(struct mail_index *index,
enum mail_index_sync_flags flags);
+/* Returns TRUE if it currently looks like syncing would return expunges. */
+bool mail_index_sync_have_any_expunges(struct mail_index *index);
/* Returns the log file seq+offsets for the area which this sync is handling. */
void mail_index_sync_get_offsets(struct mail_index_sync_ctx *ctx,
uint32_t *seq1_r, uoff_t *offset1_r,
More information about the dovecot-cvs
mailing list