changeset 4221:833f9217c1d6 HEAD

When beginning to sync from old view, don't keep the old header completely, because there may have been some important new changes. Copy only the message counts and such manually now. Fixes an error message when sometimes adding keywords.
author Timo Sirainen <timo.sirainen@movial.fi>
date Mon, 24 Apr 2006 12:19:33 +0300
parents 2af75b0379bb
children b900a7257555
files src/lib-index/mail-index-view-sync.c
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c	Mon Apr 24 12:17:20 2006 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Mon Apr 24 12:19:33 2006 +0300
@@ -163,6 +163,29 @@
 	return 0;
 }
 
+static void mail_index_view_hdr_update(struct mail_index_view *view,
+				       struct mail_index_map *map)
+{
+	/* Keep message count the same. */
+	map->hdr.next_uid = view->hdr.next_uid;
+	map->hdr.messages_count = view->hdr.messages_count;
+
+	/* Keep the old message flag counts also, although they may be
+	   somewhat stale already. We just don't want them to be more than
+	   our old messages_count. */
+	map->hdr.recent_messages_count = view->hdr.recent_messages_count;
+	map->hdr.seen_messages_count = view->hdr.seen_messages_count;
+	map->hdr.deleted_messages_count = view->hdr.deleted_messages_count;
+
+	/* Keep log position so we know where to continue syncing */
+	map->hdr.log_file_seq = view->hdr.log_file_seq;
+	map->hdr.log_file_int_offset = view->hdr.log_file_int_offset;
+	map->hdr.log_file_ext_offset = view->hdr.log_file_ext_offset;
+
+	view->hdr = map->hdr;
+	buffer_write(map->hdr_copy_buf, 0, &map->hdr, sizeof(map->hdr));
+}
+
 #define MAIL_INDEX_VIEW_VISIBLE_FLAGS_MASK \
 	(MAIL_INDEX_SYNC_TYPE_FLAGS | \
 	 MAIL_INDEX_SYNC_TYPE_KEYWORD_RESET | \
@@ -268,9 +291,7 @@
 			   another view sharing the map with us had synced
 			   itself. */
 			i_assert(map->hdr_base == map->hdr_copy_buf->data);
-			buffer_write(map->hdr_copy_buf, 0,
-				     &view->hdr, sizeof(view->hdr));
-			map->hdr = view->hdr;
+			mail_index_view_hdr_update(view, map);
 		}
 
 		i_assert(map->records_count == map->hdr.messages_count);