changeset 390:0039b676a423 HEAD

expunge fixes
author Timo Sirainen <tss@iki.fi>
date Wed, 09 Oct 2002 02:35:30 +0300
parents 60040a9d243f
children 55f04b297f87
files src/lib-index/mail-index.c
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Wed Oct 09 02:26:08 2002 +0300
+++ b/src/lib-index/mail-index.c	Wed Oct 09 02:35:30 2002 +0300
@@ -542,7 +542,7 @@
 	}
 
 	rec = (MailIndexRecord *) ((char *) index->mmap_base +
-				   sizeof(MailIndexRecord)) + idx;
+				   sizeof(MailIndexHeader)) + idx;
 	if (rec->uid < first_uid || rec->uid > last_uid) {
 		index_set_error(index, "Corrupted binary tree for index %s: "
 				"lookup returned offset to wrong UID "
@@ -777,15 +777,13 @@
 	hdr->messages_count--;
 	mail_index_mark_flag_changes(index, rec, rec->msg_flags, 0);
 
-	if ((hdr->first_hole_index - sizeof(MailIndexHeader)) /
-	    sizeof(MailIndexRecord) == hdr->messages_count) {
+	(void)mail_index_data_add_deleted_space(index->data, rec->data_size);
+
+	records = MAIL_INDEX_RECORD_COUNT(index);
+	if (hdr->first_hole_index + hdr->first_hole_records == records) {
 		/* the hole reaches end of file, truncate it */
 		(void)mail_index_truncate_hole(index);
 	} else {
-		(void)mail_index_data_add_deleted_space(index->data,
-							rec->data_size);
-
-		records = MAIL_INDEX_RECORD_COUNT(index);
 		if (INDEX_NEED_COMPRESS(records, hdr))
 			hdr->flags |= MAIL_INDEX_FLAG_COMPRESS;
 	}