]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Mbox syncing / expunging fixes for previous expunge-commit.
authorTimo Sirainen <tss@iki.fi>
Wed, 23 Jul 2003 00:29:32 +0000 (03:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 23 Jul 2003 00:29:32 +0000 (03:29 +0300)
--HG--
branch : HEAD

src/lib-index/mail-modifylog.c
src/lib-index/mbox/mbox-sync-full.c
src/lib-index/mbox/mbox-sync.c

index d98bb9502e671d990f5ca9e4422049b9efd73c9d..dec93093a7efa8ff7309943b935759edb9ca3990 100644 (file)
@@ -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;
                }
index 9e9833e82dcb3e4a269f3d1fac15a49266003c07..22314bff3375306d936d378dfa112329e4e69cf9 100644 (file)
@@ -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 */
index 6153d75592a2e2d476331b55c68ddf71583f2634..57a7fea3970ee0fe1e3414ec12e4babd29b8a4ad 100644 (file)
@@ -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;