changeset 629:2f3b2a5d74d7 HEAD

If first message with our X-IMAPbase is deleted, make sure it's added back.
author Timo Sirainen <tss@iki.fi>
date Wed, 20 Nov 2002 19:06:46 +0200
parents e4aba04143ad
children 03f23250b63d
files src/lib-index/mbox/mbox-index.c src/lib-index/mbox/mbox-rewrite.c
diffstat 2 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-index.c	Wed Nov 20 18:59:10 2002 +0200
+++ b/src/lib-index/mbox/mbox-index.c	Wed Nov 20 19:06:46 2002 +0200
@@ -740,6 +740,21 @@
 	return mail_index_try_lock(index, lock_type);
 }
 
+int mbox_index_expunge(MailIndex *index, MailIndexRecord *rec,
+		       unsigned int seq, int external_change)
+{
+	if (!mail_index_expunge(index, rec, seq, external_change))
+		return FALSE;
+
+	if (seq == 1) {
+		/* Our message containing X-IMAPbase was deleted.
+		   Get it back there. */
+		index->header->flags |= MAIL_INDEX_FLAG_DIRTY_MESSAGES |
+			MAIL_INDEX_FLAG_DIRTY_CUSTOMFLAGS;
+	}
+	return TRUE;
+}
+
 static int mbox_index_update_flags(MailIndex *index, MailIndexRecord *rec,
 				   unsigned int seq, MailFlags flags,
 				   int external_change)
@@ -772,7 +787,7 @@
 	mail_index_cache_fields_later,
 	mbox_open_mail,
 	mail_get_internal_date,
-	mail_index_expunge,
+	mbox_index_expunge,
 	mbox_index_update_flags,
 	mail_index_append_begin,
 	mail_index_append_end,
--- a/src/lib-index/mbox/mbox-rewrite.c	Wed Nov 20 18:59:10 2002 +0200
+++ b/src/lib-index/mbox/mbox-rewrite.c	Wed Nov 20 19:06:46 2002 +0200
@@ -393,6 +393,9 @@
 	return ret;
 }
 
+#define INDEX_DIRTY_FLAGS \
+        (MAIL_INDEX_FLAG_DIRTY_MESSAGES | MAIL_INDEX_FLAG_DIRTY_CUSTOMFLAGS)
+
 int mbox_index_rewrite(MailIndex *index)
 {
 	/* Write messages beginning from the first dirty one to temp file,
@@ -412,7 +415,7 @@
 	if (!index->set_lock(index, MAIL_LOCK_SHARED))
 		return FALSE;
 
-        rewrite = (index->header->flags & MAIL_INDEX_FLAG_DIRTY_MESSAGES);
+        rewrite = (index->header->flags & INDEX_DIRTY_FLAGS);
 
 	if (!index->set_lock(index, MAIL_LOCK_UNLOCK))
 		return FALSE;
@@ -435,8 +438,7 @@
 		if (inbuf == NULL)
 			break;
 
-		if ((index->header->flags &
-		     MAIL_INDEX_FLAG_DIRTY_MESSAGES) == 0) {
+		if ((index->header->flags & INDEX_DIRTY_FLAGS) == 0) {
 			/* fsck() figured out there's no dirty messages
 			   after all */
 			failed = FALSE; rewrite = FALSE;