[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c, 1.57, 1.58 mbox-sync-rewrite.c, 1.73, 1.74
tss at dovecot.org
tss at dovecot.org
Sat Mar 10 13:54:41 EET 2007
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv31258
Modified Files:
mbox-sync-parse.c mbox-sync-rewrite.c
Log Message:
When rewriting the first message we could have written next-uid field wrong.
Index: mbox-sync-parse.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- mbox-sync-parse.c 28 Feb 2007 19:55:31 -0000 1.57
+++ mbox-sync-parse.c 10 Mar 2007 11:54:39 -0000 1.58
@@ -220,18 +220,18 @@
hdr->full_value_offset + uid_last_pos;
}
- if (ctx->sync_ctx->next_uid-1 <= uid_last) {
- /* new messages have been added since our last sync.
- just update our internal next_uid. */
- ctx->sync_ctx->next_uid = uid_last+1;
- }
- i_assert(ctx->sync_ctx->next_uid > ctx->sync_ctx->prev_msg_uid);
-
if (ctx->sync_ctx->base_uid_validity == 0) {
/* first time parsing this (ie. we're not rewriting).
save the values. */
ctx->sync_ctx->base_uid_validity = uid_validity;
ctx->sync_ctx->base_uid_last = uid_last;
+
+ if (ctx->sync_ctx->next_uid-1 <= uid_last) {
+ /* new messages have been added since our last sync.
+ just update our internal next_uid. */
+ ctx->sync_ctx->next_uid = uid_last+1;
+ }
+ i_assert(ctx->sync_ctx->next_uid > ctx->sync_ctx->prev_msg_uid);
}
ctx->hdr_pos[MBOX_HDR_X_IMAPBASE] = str_len(ctx->header);
Index: mbox-sync-rewrite.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- mbox-sync-rewrite.c 9 Mar 2007 20:22:50 -0000 1.73
+++ mbox-sync-rewrite.c 10 Mar 2007 11:54:39 -0000 1.74
@@ -320,6 +320,7 @@
uoff_t expunged_space)
{
unsigned int first_mail_expunge_extra;
+ uint32_t orig_next_uid;
memset(mail_ctx, 0, sizeof(*mail_ctx));
mail_ctx->sync_ctx = sync_ctx;
@@ -335,6 +336,7 @@
/* This will force the UID to be the one that we originally assigned
to it, regardless of whether it's broken or not in the file. */
+ orig_next_uid = sync_ctx->next_uid;
sync_ctx->next_uid = mails[idx].uid;
sync_ctx->prev_msg_uid = mails[idx].uid - 1;
@@ -351,6 +353,12 @@
}
mbox_sync_parse_next_mail(sync_ctx->input, mail_ctx);
+
+ /* set next_uid back before updating the headers. this is important
+ if we're updating the first message to make X-IMAP[base] header
+ have the correct value. */
+ sync_ctx->next_uid = orig_next_uid;
+
if (mails[idx].space != 0) {
if (mails[idx].space < 0) {
/* remove all possible spacing before updating */
@@ -454,7 +462,7 @@
uoff_t offset, dest_offset, next_end_offset, next_move_diff;
uoff_t start_offset, expunged_space;
uint32_t idx, first_nonexpunged_idx, padding_per_mail;
- uint32_t orig_prev_msg_uid, orig_next_uid;
+ uint32_t orig_prev_msg_uid;
unsigned int count;
int ret = 0;
@@ -485,7 +493,6 @@
i_assert(mails[first_nonexpunged_idx].space < 0);
orig_prev_msg_uid = sync_ctx->prev_msg_uid;
- orig_next_uid = sync_ctx->next_uid;
/* start moving backwards. */
while (idx > first_nonexpunged_idx) {
@@ -563,7 +570,6 @@
i_assert(move_diff + (off_t)expunged_space >= 0);
i_stream_sync(sync_ctx->input);
- sync_ctx->next_uid = orig_next_uid;
sync_ctx->prev_msg_uid = orig_prev_msg_uid;
return ret;
}
More information about the dovecot-cvs
mailing list