[dovecot-cvs]
dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.153, 1.154
cras at dovecot.org
cras at dovecot.org
Tue Apr 26 11:11:39 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv17543
Modified Files:
mbox-sync.c
Log Message:
Dirty flags weren't being updated correctly. Caused the same messages to be
rewritten over and over again, or skipping some messages causing lost flag
changes.
Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- mbox-sync.c 23 Apr 2005 15:18:22 -0000 1.153
+++ mbox-sync.c 26 Apr 2005 08:11:37 -0000 1.154
@@ -421,21 +421,34 @@
mbox_sync_apply_index_syncs(sync_ctx, &idx_mail,
&keywords_changed);
+#define SYNC_FLAGS (MAIL_RECENT | MAIL_INDEX_MAIL_FLAG_DIRTY)
if ((idx_mail.flags & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0) {
/* flags are dirty. ignore whatever was in the mbox,
- but update recent flag state if needed. */
- mbox_flags &= MAIL_RECENT;
- mbox_flags |= idx_mail.flags & ~MAIL_RECENT;
+ but update recent/dirty flag states if needed. */
+ mbox_flags &= SYNC_FLAGS;
+ mbox_flags |= idx_mail.flags & ~SYNC_FLAGS;
} else {
/* keep index's internal flags */
- mbox_flags &= MAIL_FLAGS_MASK;
- mbox_flags |= idx_mail.flags & ~MAIL_FLAGS_MASK;
+ mbox_flags &= MAIL_FLAGS_MASK | SYNC_FLAGS;
+ mbox_flags |= idx_mail.flags &
+ ~(MAIL_FLAGS_MASK | SYNC_FLAGS);
}
- if ((idx_mail.flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY) ==
- (mbox_flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY)) {
- /* all flags are same, except possibly dirty flag */
- if (idx_mail.flags != mbox_flags) {
+ if ((idx_mail.flags & ~SYNC_FLAGS) !=
+ (mbox_flags & ~SYNC_FLAGS)) {
+ /* flags other than recent/dirty have changed */
+ mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
+ MODIFY_REPLACE, mbox_flags);
+ } else {
+ if (((idx_mail.flags ^ mbox_flags) &
+ MAIL_RECENT) != 0) {
+ /* drop recent flag (it can only be dropped) */
+ mail_index_update_flags(sync_ctx->t,
+ sync_ctx->idx_seq,
+ MODIFY_REMOVE, MAIL_RECENT);
+ }
+ if (((idx_mail.flags ^ mbox_flags) &
+ MAIL_INDEX_MAIL_FLAG_DIRTY) != 0) {
/* dirty flag state changed */
int dirty = (mbox_flags &
MAIL_INDEX_MAIL_FLAG_DIRTY) != 0;
@@ -444,15 +457,6 @@
dirty ? MODIFY_ADD : MODIFY_REMOVE,
MAIL_INDEX_MAIL_FLAG_DIRTY);
}
- } else if ((idx_mail.flags & ~MAIL_RECENT) !=
- (mbox_flags & ~MAIL_RECENT)) {
- /* flags other than MAIL_RECENT have changed */
- mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
- MODIFY_REPLACE, mbox_flags);
- } else if (((idx_mail.flags ^ mbox_flags) & MAIL_RECENT) != 0) {
- /* drop recent flag */
- mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
- MODIFY_REMOVE, MAIL_RECENT);
}
if ((idx_mail.flags & MAIL_INDEX_MAIL_FLAG_DIRTY) == 0 &&
More information about the dovecot-cvs
mailing list