changeset 4501:a7178fbf4697 HEAD

In some conditions a keyword could have been added to the index twice. Also a few cleanups.
author Timo Sirainen <tss@iki.fi>
date Mon, 24 Jul 2006 00:41:38 +0300
parents 14864c643427
children 0d465504c18a
files src/lib-index/mail-index-sync-keywords.c src/lib-index/mail-index-sync-update.c
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-keywords.c	Sun Jul 23 22:08:58 2006 +0300
+++ b/src/lib-index/mail-index-sync-keywords.c	Mon Jul 24 00:41:38 2006 +0300
@@ -20,9 +20,9 @@
 			return -1;
 		ctx->keywords_read = TRUE;
 	}
-	if (mail_index_keyword_lookup(ctx->view->index, keyword_name,
-				      FALSE, &keyword_idx) &&
-	    array_is_created(&map->keyword_idx_map)) {
+	if (array_is_created(&map->keyword_idx_map) &&
+	    mail_index_keyword_lookup(ctx->view->index, keyword_name,
+				      FALSE, &keyword_idx)) {
 		/* FIXME: slow. maybe create index -> file mapping as well */
 		idx_map = array_get(&map->keyword_idx_map, &count);
 		for (i = 0; i < count; i++) {
@@ -222,6 +222,8 @@
 	i_assert(data_offset < ext->record_size);
 	data_offset += ext->record_offset;
 
+	i_assert(data_offset >= sizeof(struct mail_index_record));
+
 	switch (type) {
 	case MODIFY_ADD:
 		for (seq1--; seq1 < seq2; seq1++) {
@@ -323,7 +325,6 @@
 	return 1;
 }
 
-
 int
 mail_index_sync_keywords_reset(struct mail_index_sync_map_ctx *ctx,
 			       const struct mail_transaction_header *hdr,
--- a/src/lib-index/mail-index-sync-update.c	Sun Jul 23 22:08:58 2006 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Mon Jul 24 00:41:38 2006 +0300
@@ -21,6 +21,8 @@
 
 	/* if map still exists after this, it's only in views. */
 	view->map->write_to_disk = FALSE;
+	/* keywords aren't parsed for the new map yet */
+	ctx->keywords_read = FALSE;
 
 	mail_index_unmap(view->index, &view->map);
 	view->map = map;