]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox rewriting should work again..
authorTimo Sirainen <tss@iki.fi>
Sun, 5 Oct 2003 17:23:38 +0000 (20:23 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 5 Oct 2003 17:23:38 +0000 (20:23 +0300)
--HG--
branch : HEAD

src/lib-index/mbox/mbox-rewrite.c
src/lib-index/mbox/mbox-sync-full.c

index d6b2e5276d67e5f43585441d85b7dc0625b7d94a..6b80fa87d59679368e345ceb71c7f8003f38122f 100644 (file)
@@ -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;
                        }
index 9799ef6b4c2b1c6ccd4ccc964b48eec108c874a1..20b88d03e7b28c628ed210170bf262083f73ad62 100644 (file)
@@ -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