[evolution-exchange] Bug #625570 - Do not free ExchangeFolder on error



commit d65b6af20ab445523fe4fc4de831ca308ef99a2f
Author: Milan Crha <mcrha redhat com>
Date:   Fri Dec 3 14:00:45 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 a473b7b..764dd83 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -611,7 +611,7 @@ exchange_folder_refresh_info_sync (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;
 
@@ -625,21 +625,24 @@ exchange_folder_refresh_info_sync (CamelFolder *folder,
 		camel_offline_journal_replay (
 			exch->journal, cancellable, NULL);
 
-		camel_exchange_utils_refresh_folder (
+		success = camel_exchange_utils_refresh_folder (
 			CAMEL_SERVICE (parent_store),
-			full_name, cancellable, NULL);
+			full_name, cancellable, 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 0661761..323787a 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -827,7 +827,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
@@ -1902,7 +1908,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)
@@ -2084,7 +2090,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;
 
@@ -2316,7 +2323,7 @@ camel_exchange_utils_refresh_folder (CamelService *service,
 	if (!mfld)
 		return FALSE;
 
-	refresh_folder_internal (mfld, cancellable, NULL);
+	refresh_folder_internal (mfld, cancellable, error);
 	sync_deletions (mfld);
 
 	return TRUE;



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