changeset 8045:f0ca5110b99d HEAD

If UIDVALIDITY changes and view hasn't noticed it yet, don't assert-crash when saving messages.
author Timo Sirainen <tss@iki.fi>
date Mon, 21 Jul 2008 03:21:25 +0300
parents 56c0494d8c49
children 8afc9ddd723e
files src/lib-index/mail-index-transaction.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction.c	Mon Jul 21 03:05:22 2008 +0300
+++ b/src/lib-index/mail-index-transaction.c	Mon Jul 21 03:21:25 2008 +0300
@@ -536,12 +536,15 @@
 
 uint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t)
 {
-	const struct mail_index_header *hdr;
+	const struct mail_index_header *head_hdr, *hdr;
 	const struct mail_index_record *recs;
 	unsigned int count, offset;
 	uint32_t next_uid;
 
-	next_uid = t->reset ? 1 : t->view->map->hdr.next_uid;
+	head_hdr = &t->view->index->map->hdr;
+	hdr = &t->view->map->hdr;
+	next_uid = t->reset || head_hdr->uid_validity != hdr->uid_validity ?
+		1 : hdr->next_uid;
 	if (array_is_created(&t->appends)) {
 		/* get next_uid from appends if they have UIDs */
 		mail_index_transaction_sort_appends(t);