[evolution-data-server/gnome-3-4] Bug #559391 - Wrong number of unread mails in folder tree
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-4] Bug #559391 - Wrong number of unread mails in folder tree
- Date: Wed, 4 Jul 2012 09:53:20 +0000 (UTC)
commit c8f4ed52aef77adbdb5a4d11506bfe8176168606
Author: Milan Crha <mcrha redhat com>
Date: Wed Jul 4 11:52:55 2012 +0200
Bug #559391 - Wrong number of unread mails in folder tree
camel/camel-folder-summary.c | 63 ++++++++++++++++++++---------------------
1 files changed, 31 insertions(+), 32 deletions(-)
---
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 8fe89fd..eb53e71 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -481,15 +481,9 @@ 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"));
@@ -501,25 +495,12 @@ summary_header_to_db (CamelFolderSummary *summary,
record->nextuid = summary->priv->nextuid;
record->time = summary->time;
- /* 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;
+ 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;
return record;
}
@@ -2223,6 +2204,7 @@ camel_folder_summary_load_from_db (CamelFolderSummary *summary,
g_return_val_if_fail (CAMEL_IS_FOLDER_SUMMARY (summary), FALSE);
+ camel_folder_summary_lock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
camel_folder_summary_save_to_db (summary, NULL);
/* struct _db_pass_data data; */
@@ -2230,8 +2212,10 @@ camel_folder_summary_load_from_db (CamelFolderSummary *summary,
full_name = camel_folder_get_full_name (summary->priv->folder);
parent_store = camel_folder_get_parent_store (summary->priv->folder);
- if (!camel_folder_summary_header_load_from_db (summary, parent_store, full_name, error))
+ if (!camel_folder_summary_header_load_from_db (summary, parent_store, full_name, error)) {
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
+ }
cdb = parent_store->cdb_r;
@@ -2248,6 +2232,8 @@ camel_folder_summary_load_from_db (CamelFolderSummary *summary,
} else if (local_error != NULL)
g_propagate_error (error, local_error);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
+
return ret == 0;
}
@@ -2577,28 +2563,30 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary,
parent_store = camel_folder_get_parent_store (summary->priv->folder);
cdb = parent_store->cdb_w;
+ camel_folder_summary_lock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
+
d(printf ("\ncamel_folder_summary_save_to_db called \n"));
if (summary->priv->need_preview && g_hash_table_size (summary->priv->preview_updates)) {
- camel_folder_summary_lock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
-
camel_db_begin_transaction (parent_store->cdb_w, NULL);
g_hash_table_foreach (summary->priv->preview_updates, (GHFunc) msg_save_preview, summary->priv->folder);
g_hash_table_remove_all (summary->priv->preview_updates);
camel_db_end_transaction (parent_store->cdb_w, NULL);
-
- camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
}
summary->flags &= ~CAMEL_SUMMARY_DIRTY;
count = cfs_count_dirty (summary);
- if (!count)
- return camel_folder_summary_header_save_to_db (summary, error);
+ if (!count) {
+ gboolean res = camel_folder_summary_header_save_to_db (summary, error);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
+ return res;
+ }
ret = save_message_infos_to_db (summary, FALSE, error);
if (ret != 0) {
/* Failed, so lets reset the flag */
summary->flags |= CAMEL_SUMMARY_DIRTY;
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
@@ -2619,6 +2607,7 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary,
ret = save_message_infos_to_db (summary, FALSE, error);
if (ret != 0) {
summary->flags |= CAMEL_SUMMARY_DIRTY;
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
}
@@ -2626,6 +2615,7 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary,
record = CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->summary_header_to_db (summary, error);
if (!record) {
summary->flags |= CAMEL_SUMMARY_DIRTY;
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
@@ -2638,10 +2628,12 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary,
if (ret != 0) {
camel_db_abort_transaction (cdb, NULL);
summary->flags |= CAMEL_SUMMARY_DIRTY;
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
camel_db_end_transaction (cdb, NULL);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return ret == 0;
}
@@ -2662,11 +2654,13 @@ camel_folder_summary_header_save_to_db (CamelFolderSummary *summary,
parent_store = camel_folder_get_parent_store (summary->priv->folder);
cdb = parent_store->cdb_w;
+ camel_folder_summary_lock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
d(printf ("\ncamel_folder_summary_header_save_to_db called \n"));
record = CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->summary_header_to_db (summary, error);
if (!record) {
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
@@ -2678,10 +2672,12 @@ camel_folder_summary_header_save_to_db (CamelFolderSummary *summary,
if (ret != 0) {
camel_db_abort_transaction (cdb, NULL);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return FALSE;
}
camel_db_end_transaction (cdb, NULL);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
return ret == 0;
}
@@ -2703,6 +2699,7 @@ camel_folder_summary_header_load_from_db (CamelFolderSummary *summary,
d(printf ("\ncamel_folder_summary_header_load_from_db called \n"));
+ camel_folder_summary_lock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
camel_folder_summary_save_to_db (summary, NULL);
cdb = store->cdb_r;
@@ -2712,6 +2709,8 @@ camel_folder_summary_header_load_from_db (CamelFolderSummary *summary,
ret = CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->summary_header_from_db (summary, record);
+ camel_folder_summary_unlock (summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
+
g_free (record->folder_name);
g_free (record->bdata);
g_free (record);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]