[dovecot-cvs] dovecot/src/lib-index mail-index-sync.c, 1.27,
1.28 mail-index-view-sync.c, 1.17, 1.18 mail-index.h, 1.124, 1.125
cras at dovecot.org
cras at dovecot.org
Mon Jul 26 21:52:09 EEST 2004
Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv23472/lib-index
Modified Files:
mail-index-sync.c mail-index-view-sync.c mail-index.h
Log Message:
Fixed recent flags with mbox.
Index: mail-index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mail-index-sync.c 4 Jul 2004 11:50:49 -0000 1.27
+++ mail-index-sync.c 26 Jul 2004 18:52:06 -0000 1.28
@@ -174,7 +174,31 @@
return 0;
}
-static int mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx)
+static int mail_index_sync_add_recent_updates(struct mail_index_sync_ctx *ctx)
+{
+ struct mail_transaction_flag_update update;
+ const struct mail_index_record *rec;
+ uint32_t seq, messages_count;
+
+ memset(&update, 0, sizeof(update));
+
+ messages_count = mail_index_view_get_message_count(ctx->view);
+ for (seq = 1; seq <= messages_count; seq++) {
+ if (mail_index_lookup(ctx->view, seq, &rec) < 0)
+ return -1;
+
+ if ((rec->flags & MAIL_RECENT) == 0)
+ continue;
+
+ update.uid1 = update.uid2 = rec->uid;
+ mail_index_sync_sort_flags(ctx->updates_buf,
+ &update, sizeof(update));
+ }
+ return 0;
+}
+
+static int
+mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx, int sync_recent)
{
size_t size;
int ret;
@@ -185,6 +209,11 @@
return -1;
}
+ if (sync_recent) {
+ if (mail_index_sync_add_recent_updates(ctx) < 0)
+ return -1;
+ }
+
while ((ret = mail_transaction_log_view_next(ctx->view->log_view,
&ctx->hdr,
&ctx->data, NULL)) > 0) {
@@ -200,9 +229,12 @@
return ret;
}
-static int mail_index_need_lock(struct mail_index *index,
+static int mail_index_need_lock(struct mail_index *index, int sync_recent,
uint32_t log_file_seq, uoff_t log_file_offset)
{
+ if (sync_recent && index->hdr->recent_messages_count > 0)
+ return 1;
+
if (index->hdr->log_file_seq > log_file_seq ||
(index->hdr->log_file_seq == log_file_seq &&
index->hdr->log_file_offset >= log_file_offset)) {
@@ -216,7 +248,8 @@
int mail_index_sync_begin(struct mail_index *index,
struct mail_index_sync_ctx **ctx_r,
struct mail_index_view **view_r,
- uint32_t log_file_seq, uoff_t log_file_offset)
+ uint32_t log_file_seq, uoff_t log_file_offset,
+ int sync_recent)
{
struct mail_index_sync_ctx *ctx;
uint32_t seq;
@@ -237,7 +270,8 @@
return -1;
}
- if (!mail_index_need_lock(index, log_file_seq, log_file_offset)) {
+ if (!mail_index_need_lock(index, sync_recent,
+ log_file_seq, log_file_offset)) {
mail_index_unlock(index, lock_id);
mail_transaction_log_sync_unlock(index->log);
return 0;
@@ -265,7 +299,7 @@
1024, (size_t)-1);
ctx->updates_buf = buffer_create_dynamic(default_pool,
1024, (size_t)-1);
- if (mail_index_sync_read_and_sort(ctx) < 0) {
+ if (mail_index_sync_read_and_sort(ctx, sync_recent) < 0) {
mail_index_sync_end(ctx);
return -1;
}
Index: mail-index-view-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mail-index-view-sync.c 18 Jul 2004 12:31:27 -0000 1.17
+++ mail-index-view-sync.c 26 Jul 2004 18:52:07 -0000 1.18
@@ -218,7 +218,8 @@
}
#define FLAG_UPDATE_IS_INTERNAL(u, empty) \
- (((u)->add_flags | (u)->remove_flags) == MAIL_INDEX_MAIL_FLAG_DIRTY && \
+ ((((u)->add_flags | (u)->remove_flags) & \
+ ~(MAIL_INDEX_MAIL_FLAG_DIRTY | MAIL_RECENT)) == 0 && \
memcmp((u)->add_keywords, empty, INDEX_KEYWORDS_BYTE_COUNT) == 0 && \
memcmp((u)->add_keywords, empty, INDEX_KEYWORDS_BYTE_COUNT) == 0)
Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- mail-index.h 3 Jul 2004 20:17:37 -0000 1.124
+++ mail-index.h 26 Jul 2004 18:52:07 -0000 1.125
@@ -210,7 +210,8 @@
int mail_index_sync_begin(struct mail_index *index,
struct mail_index_sync_ctx **ctx_r,
struct mail_index_view **view_r,
- uint32_t log_file_seq, uoff_t log_file_offset);
+ uint32_t log_file_seq, uoff_t log_file_offset,
+ int sync_recent);
/* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */
int mail_index_sync_next(struct mail_index_sync_ctx *ctx,
struct mail_index_sync_rec *sync_rec);
More information about the dovecot-cvs
mailing list