[evolution-exchange/gnome-2-32] Bug #625570 - Do not free ExchangeFolder on error



commit e57be03c2a3a6220c3d6db548f792755259c1c81
Author: Milan Crha <mcrha redhat com>
Date:   Fri Dec 3 14:02:09 2010 +0100

    Bug #625570 - Do not free ExchangeFolder on error

 camel/camel-exchange-folder.c |   23 +++++++++++++----------
 camel/camel-exchange-utils.c  |   15 +++++++++++----
 2 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/camel/camel-exchange-folder.c b/camel/camel-exchange-folder.c
index b350c92..9ef0fd4 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -345,7 +345,7 @@ exchange_folder_refresh_info (CamelFolder *folder,
 	CamelExchangeFolder *exch;
 	CamelExchangeStore *store;
 	CamelStore *parent_store;
-	guint32 unread_count, visible_count;
+	guint32 unread_count = -1, visible_count = -1;
 	const gchar *full_name;
 	gboolean success = TRUE;
 
@@ -358,20 +358,23 @@ exchange_folder_refresh_info (CamelFolder *folder,
 	if (camel_exchange_store_connected (store, NULL)) {
 		camel_offline_journal_replay (exch->journal, NULL);
 
-		camel_exchange_utils_refresh_folder (
-			CAMEL_SERVICE (parent_store), full_name, NULL);
+		success = camel_exchange_utils_refresh_folder (
+			CAMEL_SERVICE (parent_store), full_name, error);
 	}
 
 	/* sync up the counts now */
-	if (!camel_exchange_utils_sync_count (
+	success = success && camel_exchange_utils_sync_count (
 		CAMEL_SERVICE (parent_store), full_name,
-		&unread_count, &visible_count, error)) {
-		g_print("\n Error syncing up the counts");
-		success = FALSE;
-	}
+		&unread_count, &visible_count, error);
+
+	success = success && (!error || !*error);
 
-	folder->summary->unread_count = unread_count;
-	folder->summary->visible_count = visible_count;
+	if (success) {
+		folder->summary->unread_count = unread_count;
+		folder->summary->visible_count = visible_count;
+	} else if (error && !*error) {
+		g_set_error (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, "%s", _("Could not get new messages"));
+	}
 
 	return success;
 }
diff --git a/camel/camel-exchange-utils.c b/camel/camel-exchange-utils.c
index cd07333..d392e2c 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -824,7 +824,13 @@ got_folder_error (ExchangeFolder *mfld, GError **error, const gchar *err)
 {
 	set_exception (error, err);
 
-	free_folder (mfld);
+	g_return_if_fail (mfld != NULL);
+	g_return_if_fail (mfld->ed != NULL);
+
+	/* DO NOT remove folder here, it is pretty confused when gets back online */
+
+	/* this also calls free_folder() */
+	/* g_hash_table_remove (mfld->ed->folders_by_name, mfld->name); */
 }
 
 static void
@@ -1909,7 +1915,7 @@ get_folder_info_data (ExchangeData *ed, const gchar *top, guint32 store_flags, G
 
 	mode = is_online (ed);
 	if (!subscribed && subscription_list) {
-		ExchangeAccountResult result = -1;
+		ExchangeAccountFolderResult result = -1;
 
 		d(g_print ("%s(%d):%s: NOT SUBSCRIBED top = [%s]\n", __FILE__, __LINE__, G_STRFUNC, top));
 		if (!toplen)
@@ -2091,7 +2097,8 @@ folder_update_linestatus (gpointer key, gpointer value, gpointer data)
 	if (ul->linestatus == ONLINE_MODE) {
 		CamelFolder *folder;
 
-		get_folder_online (mfld, ul->error);
+		if (!get_folder_online (mfld, ul->error))
+			return;
 
 		readonly = (mfld->access & (MAPI_ACCESS_MODIFY | MAPI_ACCESS_CREATE_CONTENTS)) ? 0 : 1;
 
@@ -2322,7 +2329,7 @@ camel_exchange_utils_refresh_folder (CamelService *service,
 	if (!mfld)
 		return FALSE;
 
-	refresh_folder_internal (mfld, NULL);
+	refresh_folder_internal (mfld, error);
 	sync_deletions (mfld);
 
 	return TRUE;



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