Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog	(revision 8534)
+++ camel/providers/imap/ChangeLog	(working copy)
@@ -1,3 +1,15 @@
+2008-02-26  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #324804
+
+	* camel-imap-folder.h: (camel_imap_folder_changed):
+	Changed function prototype, added parameter to indicate whether we just
+	recreating summary, in that case not all messages are considered as new.
+	* camel-imap-folder.c: (camel_imap_folder_selected), (imap_rescan),
+	(imap_update_summary), (camel_imap_folder_changed):
+	* camel-imap-command.c: (camel_imap_response_free):
+	Propagate function prototype change.
+
 2008-02-18  Chenthill Palanisamy  <pchenthill@novell.com>
 
 	* camel-imap-store.c (connect_to_server): Fix for some
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 8534)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -364,7 +364,7 @@ camel_imap_folder_selected (CamelFolder 
 		camel_imap_message_cache_clear (imap_folder->cache);
 		CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock);
 		imap_folder->need_rescan = FALSE;
-		camel_imap_folder_changed (folder, exists, NULL, ex);
+		camel_imap_folder_changed (folder, exists, NULL, TRUE, ex);
 		return;
 	}
 
@@ -422,7 +422,7 @@ camel_imap_folder_selected (CamelFolder 
 	 * have been added, find out about them.
 	 */
 	if (exists > count)
-		camel_imap_folder_changed (folder, exists, NULL, ex);
+		camel_imap_folder_changed (folder, exists, NULL, FALSE, ex);
 
 	/* And we're done. */
 }
@@ -674,7 +674,7 @@ imap_rescan (CamelFolder *folder, int ex
 	summary_len = camel_folder_summary_count (folder->summary);
 	if (summary_len == 0) {
 		if (exists)
-			camel_imap_folder_changed (folder, exists, NULL, ex);
+			camel_imap_folder_changed (folder, exists, NULL, FALSE, ex);
 		return;
 	}
 
@@ -789,7 +789,7 @@ imap_rescan (CamelFolder *folder, int ex
 		g_array_append_val (removed, seq);
 
 	/* And finally update the summary. */
-	camel_imap_folder_changed (folder, exists, removed, ex);
+	camel_imap_folder_changed (folder, exists, removed, FALSE, ex);
 	g_array_free (removed, TRUE);
 }
 
@@ -2475,7 +2475,7 @@ construct_junk_headers (char *header, ch
 
 static void
 imap_update_summary (CamelFolder *folder, int exists,
-		     CamelFolderChangeInfo *changes,
+		     CamelFolderChangeInfo *changes, gboolean is_recreate,
 		     CamelException *ex)
 {
 	CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
@@ -2756,8 +2756,9 @@ imap_update_summary (CamelFolder *folder
 		camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
 
 		/* report all new messages as recent, even without that flag, thus new
-		   messages will be filtered even after saw by other software earlier */
-		if ((mi->info.flags & CAMEL_IMAP_MESSAGE_RECENT) != 0 || getenv ("FILTER_RECENT") == NULL)
+		   messages will be filtered even after saw by other software earlier.
+		   Do not filter seen messages when recreating summary for the folder. */
+		if ((mi->info.flags & CAMEL_IMAP_MESSAGE_RECENT) != 0 || (!is_recreate && getenv ("FILTER_RECENT") == NULL))
 			camel_folder_change_info_recent_uid (changes, camel_message_info_uid (mi));
 	}
 
@@ -2790,7 +2791,7 @@ imap_update_summary (CamelFolder *folder
 /* Called with the store's connect_lock locked */
 void
 camel_imap_folder_changed (CamelFolder *folder, int exists,
-			   GArray *expunged, CamelException *ex)
+			   GArray *expunged, gboolean is_recreate, CamelException *ex)
 {
 	CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
 	extern int camel_application_is_exiting;
@@ -2822,7 +2823,7 @@ camel_imap_folder_changed (CamelFolder *
 
 	len = camel_folder_summary_count (folder->summary);
 	if (exists > len && !camel_application_is_exiting)
-		imap_update_summary (folder, exists, changes, ex);
+		imap_update_summary (folder, exists, changes, is_recreate, ex);
 
 	if (camel_folder_change_info_changed (changes))
 		camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
Index: camel/providers/imap/camel-imap-command.c
===================================================================
--- camel/providers/imap/camel-imap-command.c	(revision 8534)
+++ camel/providers/imap/camel-imap-command.c	(working copy)
@@ -613,7 +613,7 @@ camel_imap_response_free (CamelImapStore
 		if (exists > 0 || expunged) {
 			/* Update the summary */
 			camel_imap_folder_changed (response->folder,
-						   exists, expunged, NULL);
+						   exists, expunged, FALSE, NULL);
 			if (expunged)
 				g_array_free (expunged, TRUE);
 		}
Index: camel/providers/imap/camel-imap-folder.h
===================================================================
--- camel/providers/imap/camel-imap-folder.h	(revision 8534)
+++ camel/providers/imap/camel-imap-folder.h	(working copy)
@@ -80,7 +80,7 @@ void camel_imap_folder_selected (CamelFo
 				 CamelException *ex);
 
 void camel_imap_folder_changed (CamelFolder *folder, int exists,
-				GArray *expunged, CamelException *ex);
+				GArray *expunged, gboolean is_recreate, CamelException *ex);
 
 CamelStream *camel_imap_folder_fetch_data (CamelImapFolder *imap_folder,
 					   const char *uid,
