Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5257:c073fad758d5 HEAD
When rewriting the first message we could have written next-uid field wrong.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 10 Mar 2007 13:54:39 +0200 |
parents | d66f62eb69b3 |
children | 1fffd36401eb |
files | src/lib-storage/index/mbox/mbox-sync-parse.c src/lib-storage/index/mbox/mbox-sync-rewrite.c |
diffstat | 2 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-parse.c Fri Mar 09 23:21:02 2007 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync-parse.c Sat Mar 10 13:54:39 2007 +0200 @@ -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);
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c Fri Mar 09 23:21:02 2007 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c Sat Mar 10 13:54:39 2007 +0200 @@ -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; }