From: Timo Sirainen Date: Sun, 5 Oct 2003 17:23:38 +0000 (+0300) Subject: mbox rewriting should work again.. X-Git-Tag: 1.1.alpha1~4306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24271209471a72513dee83b4a0149b01e37e772f;p=thirdparty%2Fdovecot%2Fcore.git mbox rewriting should work again.. --HG-- branch : HEAD --- diff --git a/src/lib-index/mbox/mbox-rewrite.c b/src/lib-index/mbox/mbox-rewrite.c index d6b2e5276d..6b80fa87d5 100644 --- a/src/lib-index/mbox/mbox-rewrite.c +++ b/src/lib-index/mbox/mbox-rewrite.c @@ -48,7 +48,9 @@ static int reset_dirty_flags(struct mail_index *index) while (rec != NULL) { index_flags = mail_cache_get_index_flags(index->cache, rec); if ((index_flags & MAIL_INDEX_FLAG_DIRTY) != 0) { - if (!mail_cache_update_index_flags(index->cache, rec, index_flags)) + index_flags &= ~MAIL_INDEX_FLAG_DIRTY; + if (!mail_cache_update_index_flags(index->cache, + rec, index_flags)) return FALSE; } @@ -76,7 +78,7 @@ static int mbox_write(struct mail_index *index, struct istream *input, strerror(output->stream_errno)); failed = TRUE; } else if (input->v_offset < end_offset) { - /* fsck should have noticed it.. */ + /* sync should have noticed it.. */ index_set_error(index, "Error rewriting mbox file %s: " "Unexpected end of file", index->mailbox_path); failed = TRUE; @@ -382,7 +384,6 @@ static int write_header(struct mbox_rewrite_context *ctx, static int mbox_write_header(struct mail_index *index, struct mail_index_record *rec, unsigned int seq, struct istream *input, struct ostream *output, - uoff_t end_offset, uoff_t *hdr_input_size, uoff_t body_size) { /* We need to update fields that define message flags. Standard fields @@ -403,13 +404,6 @@ static int mbox_write_header(struct mail_index *index, uoff_t offset; int force_filler; - if (input->v_offset >= end_offset) { - /* fsck should have noticed it.. */ - index_set_error(index, "Error rewriting mbox file %s: " - "Unexpected end of file", index->mailbox_path); - return FALSE; - } - t_push(); /* parse the header, write the fields we don't want to change */ @@ -712,7 +706,7 @@ int mbox_index_rewrite(struct mail_index *index) /* write header, updating flag fields */ if (!mbox_write_header(index, rec, seq, input, output, - offset, &hdr_size, body_size)) { + &hdr_size, body_size)) { failed = TRUE; break; } diff --git a/src/lib-index/mbox/mbox-sync-full.c b/src/lib-index/mbox/mbox-sync-full.c index 9799ef6b4c..20b88d03e7 100644 --- a/src/lib-index/mbox/mbox-sync-full.c +++ b/src/lib-index/mbox/mbox-sync-full.c @@ -150,9 +150,13 @@ static int match_next_record(struct mail_index *index, MODIFY_REPLACE, ctx.flags, TRUE)) return FALSE; + } else if (rec->msg_flags == ctx.flags) { + /* flags are same, it's not dirty anymore */ + index_flags &= ~MAIL_INDEX_FLAG_DIRTY; + mail_cache_update_index_flags(index->cache, + rec, index_flags); } else { - if (rec->msg_flags != ctx.flags) - *dirty = TRUE; + *dirty = TRUE; } /* update location */ @@ -200,6 +204,10 @@ static int mbox_sync_from_stream(struct mail_index *index, unsigned int seq; int dirty; + if (mail_cache_lock(index->cache, FALSE) <= 0) + return FALSE; + mail_cache_unlock_later(index->cache); + mbox_skip_empty_lines(input); /* first make sure we start with a "From " line. If file is too