From: Timo Sirainen Date: Wed, 23 Jul 2003 00:29:32 +0000 (+0300) Subject: Mbox syncing / expunging fixes for previous expunge-commit. X-Git-Tag: 1.1.alpha1~4470 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e53bbd90c0e1e62e648f6902732a04463d32498;p=thirdparty%2Fdovecot%2Fcore.git Mbox syncing / expunging fixes for previous expunge-commit. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-modifylog.c b/src/lib-index/mail-modifylog.c index d98bb9502e..dec93093a7 100644 --- a/src/lib-index/mail-modifylog.c +++ b/src/lib-index/mail-modifylog.c @@ -797,7 +797,7 @@ int mail_modifylog_add_expunges(struct mail_modify_log *log, /* note that the weird looking logic above is correct. it's because of reordered seq numbers. */ i_assert(first_uid > file->last_expunge->uid2); - file->last_expunge->seq2 = last_seq; + file->last_expunge->seq2 += (last_seq - first_seq) + 1; file->last_expunge->uid2 = last_uid; return TRUE; } diff --git a/src/lib-index/mbox/mbox-sync-full.c b/src/lib-index/mbox/mbox-sync-full.c index 9e9833e82d..22314bff33 100644 --- a/src/lib-index/mbox/mbox-sync-full.c +++ b/src/lib-index/mbox/mbox-sync-full.c @@ -121,7 +121,7 @@ static int mbox_check_uidvalidity(struct mail_index *index, static int match_next_record(struct mail_index *index, struct mail_index_record *rec, - unsigned int seq, struct istream *input, + unsigned int *seq, struct istream *input, struct mail_index_record **next_rec, int *dirty) { struct mail_index_update *update; @@ -167,7 +167,7 @@ static int match_next_record(struct mail_index *index, mbox_header_cb, &ctx); md5_final(&ctx.md5, current_digest); - if (seq == 1) { + if (*seq == 1) { if (!mbox_check_uidvalidity(index, ctx.uid_validity)) { /* uidvalidity changed, abort */ @@ -194,7 +194,7 @@ static int match_next_record(struct mail_index *index, /* update flags, unless we've changed them */ if ((rec->index_flags & INDEX_MAIL_FLAG_DIRTY) == 0) { - if (!index->update_flags(index, rec, seq, + if (!index->update_flags(index, rec, *seq, ctx.flags, TRUE)) return FALSE; @@ -231,22 +231,24 @@ static int match_next_record(struct mail_index *index, /* try next message */ if (first_rec == NULL) { first_rec = rec; - first_seq = seq; + first_seq = *seq; } last_rec = rec; - last_seq = seq; + last_seq = *seq; - rec = index->next(index, rec); seq++; + rec = index->next(index, rec); *seq += 1; } while (rec != NULL); - if (first_rec == NULL) + if (first_rec == NULL) { + *seq += 1; *next_rec = rec == NULL ? NULL : index->next(index, rec); - else { + } else { if (!index->expunge(index, first_rec, last_rec, first_seq, last_seq, TRUE)) return FALSE; - *next_rec = index->lookup(index, first_seq); + *seq = first_seq + 1; + *next_rec = index->lookup(index, *seq); } return TRUE; @@ -304,16 +306,13 @@ static int mbox_sync_from_stream(struct mail_index *index, if (input->v_offset == input->v_size) break; - if (!match_next_record(index, rec, seq, input, &rec, &dirty)) + if (!match_next_record(index, rec, &seq, input, &rec, &dirty)) return FALSE; - if (rec == NULL) { + if (rec == NULL && seq <= index->header->messages_count) { /* Get back to line before From */ i_stream_seek(input, from_offset); - break; } - - seq++; } /* delete the rest of the records */ diff --git a/src/lib-index/mbox/mbox-sync.c b/src/lib-index/mbox/mbox-sync.c index 6153d75592..57a7fea397 100644 --- a/src/lib-index/mbox/mbox-sync.c +++ b/src/lib-index/mbox/mbox-sync.c @@ -73,8 +73,6 @@ int mbox_index_sync(struct mail_index *index, int minimal_sync __attr_unused__, uoff_t filesize; int count, fd; - i_assert(index->lock_type != MAIL_LOCK_SHARED); - if (index->mailbox_readonly && data_lock_type == MAIL_LOCK_EXCLUSIVE) { index_set_error(index, "sync: %s is read-only, " "can't get exclusive lock", @@ -90,6 +88,8 @@ int mbox_index_sync(struct mail_index *index, int minimal_sync __attr_unused__, return TRUE; } + i_assert(index->lock_type != MAIL_LOCK_SHARED); + if (index->fd == -1) { /* anon-mmaped */ index_mtime = index->file_sync_stamp;