[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-update.c, 1.19, 1.20 mbox-sync.c, 1.59, 1.60

cras at dovecot.org cras at dovecot.org
Mon Jul 26 21:52:09 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv23472/lib-storage/index/mbox

Modified Files:
	mbox-sync-update.c mbox-sync.c 
Log Message:
Fixed recent flags with mbox.



Index: mbox-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-update.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mbox-sync-update.c	28 Jun 2004 22:03:24 -0000	1.19
+++ mbox-sync-update.c	26 Jul 2004 18:52:07 -0000	1.20
@@ -143,8 +143,6 @@
 
 	if (ctx->hdr_pos[MBOX_HDR_STATUS] == (size_t)-1 &&
 	    (ctx->mail.flags & STATUS_FLAGS_MASK) != 0) {
-		if (!ctx->sync_ctx->ibox->keep_recent)
-                        ctx->mail.flags |= MBOX_NONRECENT;
 		str_append(ctx->header, "Status: ");
 		ctx->hdr_pos[MBOX_HDR_STATUS] = str_len(ctx->header);
 		status_flags_append(ctx, mbox_status_flags);
@@ -292,6 +290,11 @@
 						    ctx->mail.keywords);
 		}
 
+		/* keep our old recent flag. especially because we use it
+		   negatively as non-recent */
+		ctx->mail.flags = (ctx->mail.flags & ~MAIL_RECENT) |
+			(old_flags & MAIL_RECENT);
+
 		if ((old_flags & STATUS_FLAGS_MASK) !=
 		    (ctx->mail.flags & STATUS_FLAGS_MASK))
 			mbox_sync_update_status(ctx);

Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- mbox-sync.c	12 Jul 2004 11:35:51 -0000	1.59
+++ mbox-sync.c	26 Jul 2004 18:52:07 -0000	1.60
@@ -215,6 +215,7 @@
 		if (!sync_ctx->ibox->keep_recent) {
 			/* need to add 'O' flag to Status-header */
 			mail_ctx->need_rewrite = TRUE;
+			mail_ctx->mail.flags |= MBOX_NONRECENT;
 		}
 		index_mailbox_set_recent(sync_ctx->ibox,
 					 mail_ctx->seq - mail_ctx->pseudo);
@@ -471,17 +472,21 @@
 					    &idx_flags, idx_keywords);
 
 		mbox_flags = (rec->flags & ~MAIL_FLAGS_MASK) |
-			(mail->flags & (MAIL_FLAGS_MASK^MAIL_RECENT));
-
-		if (!sync_ctx->ibox->keep_recent)
-			mbox_flags &= ~MAIL_RECENT;
+			(mail->flags & MAIL_FLAGS_MASK);
+		mbox_flags ^= MAIL_RECENT;
 
-		if (idx_flags != mbox_flags ||
+		if ((idx_flags & ~MAIL_RECENT) != (mbox_flags & ~MAIL_RECENT) ||
 		    memcmp(idx_keywords, mail->keywords,
 			   INDEX_KEYWORDS_BYTE_COUNT) != 0) {
 			mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
 						MODIFY_REPLACE, mbox_flags,
 						mail->keywords);
+		} else if (((idx_flags ^ mbox_flags) & MAIL_RECENT) != 0) {
+			/* drop recent flag */
+			memset(idx_keywords, 0, INDEX_KEYWORDS_BYTE_COUNT);
+			mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
+						MODIFY_REMOVE, MAIL_RECENT,
+						idx_keywords);
 		}
 	}
 
@@ -1173,7 +1178,7 @@
 	uint32_t seq;
 	uoff_t offset;
 	unsigned int lock_id = 0;
-	int ret, lock_type;
+	int ret, changed, lock_type;
 
 	if (lock) {
 		if (mbox_lock(ibox, F_RDLCK, &lock_id) <= 0)
@@ -1181,18 +1186,15 @@
 	}
 
 	if (sync_header)
-		ret = 0;
+		changed = 0;
 	else {
-		if ((ret = mbox_sync_has_changed(ibox)) < 0) {
+		if ((changed = mbox_sync_has_changed(ibox)) < 0) {
 			if (lock)
 				(void)mbox_unlock(ibox, lock_id);
 			return -1;
 		}
 	}
 
-	if (ret == 0 && !last_commit)
-		return 0;
-
 	if (last_commit) {
 		seq = ibox->commit_log_file_seq;
 		offset = ibox->commit_log_file_offset;
@@ -1202,13 +1204,21 @@
 	}
 
 	ret = mail_index_sync_begin(ibox->index, &index_sync_ctx, &sync_view,
-				    seq, offset);
+				    seq, offset, !ibox->keep_recent);
 	if (ret <= 0) {
 		if (ret < 0)
 			mail_storage_set_index_error(ibox);
 		return ret;
 	}
 
+	if (!changed && !mail_index_sync_have_more(index_sync_ctx)) {
+		if (mail_index_sync_end(index_sync_ctx) < 0) {
+			mail_storage_set_index_error(ibox);
+			return -1;
+		}
+		return 0;
+	}
+
 	memset(&sync_ctx, 0, sizeof(sync_ctx));
 	sync_ctx.ibox = ibox;
 	sync_ctx.from_line = str_new(default_pool, 256);
@@ -1263,7 +1273,7 @@
 		ret = mail_index_sync_begin(ibox->index,
 					    &sync_ctx.index_sync_ctx,
 					    &sync_ctx.sync_view,
-					    (uint32_t)-1, (uoff_t)-1);
+					    (uint32_t)-1, (uoff_t)-1, FALSE);
 		if (ret < 0)
 			mail_storage_set_index_error(ibox);
 		else {



More information about the dovecot-cvs mailing list