[evolution-data-server] Bug 559391 - Wrong number of unread mails in folder tree



commit 963e448dd68b5ffd335c8d11e342cc0f6e30db59
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jul 14 08:37:14 2012 -0400

    Bug 559391 - Wrong number of unread mails in folder tree
    
    This reverts part of the original fix for this bug which stopped reading
    from the summary database and caused all kinds crazy message counts to
    appear in Evolution's folder tree (often negative counts, or negative
    counts cast to an unsigned integer).
    
    Message counts are back to normal now.
    
    Reverts part of commit 42489b26c45956c66186a5dc96083437cf7a579a.

 camel/camel-folder-summary.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 1332d2d..fb0c673 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -503,9 +503,15 @@ summary_header_to_db (CamelFolderSummary *summary,
                       GError **error)
 {
 	CamelFIRecord * record = g_new0 (CamelFIRecord, 1);
+	CamelStore *parent_store;
+	CamelDB *db;
 	const gchar *table_name;
 
+	/* Though we are going to read, we do this during write,
+	 * so lets use it that way. */
 	table_name = camel_folder_get_full_name (summary->priv->folder);
+	parent_store = camel_folder_get_parent_store (summary->priv->folder);
+	db = parent_store->cdb_w;
 
 	io(printf("Savining header to db\n"));
 
@@ -517,12 +523,27 @@ summary_header_to_db (CamelFolderSummary *summary,
 	record->nextuid = summary->priv->nextuid;
 	record->time = summary->time;
 
-	record->saved_count = summary->priv->saved_count;
-	record->junk_count = summary->priv->junk_count;
-	record->deleted_count = summary->priv->deleted_count;
-	record->unread_count = summary->priv->unread_count;
-	record->visible_count = summary->priv->visible_count;
-	record->jnd_count = summary->priv->junk_not_deleted_count;
+	if (!is_in_memory_summary (summary)) {
+		/* FIXME: Ever heard of Constructors and initializing ? */
+		if (camel_db_count_total_message_info (db, table_name, &(record->saved_count), NULL))
+			record->saved_count = 0;
+		if (camel_db_count_junk_message_info (db, table_name, &(record->junk_count), NULL))
+			record->junk_count = 0;
+		if (camel_db_count_deleted_message_info (db, table_name, &(record->deleted_count), NULL))
+			record->deleted_count = 0;
+		if (camel_db_count_unread_message_info (db, table_name, &(record->unread_count), NULL))
+			record->unread_count = 0;
+		if (camel_db_count_visible_message_info (db, table_name, &(record->visible_count), NULL))
+			record->visible_count = 0;
+		if (camel_db_count_junk_not_deleted_message_info (db, table_name, &(record->jnd_count), NULL))
+			record->jnd_count = 0;
+	}
+
+	summary->priv->unread_count = record->unread_count;
+	summary->priv->deleted_count = record->deleted_count;
+	summary->priv->junk_count = record->junk_count;
+	summary->priv->visible_count = record->visible_count;
+	summary->priv->junk_not_deleted_count = record->jnd_count;
 
 	return record;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]