evolution-data-server r9237 - trunk/camel/providers/imap



Author: sragavan
Date: Thu Jul 31 10:31:51 2008
New Revision: 9237
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9237&view=rev

Log:
2008-07-31  Srinivasa Ragavan  <sragavan novell com>

	** Fix for bug #545081

	* camel/providers/imap/camel-imap-message-cache.c: Add a new simple
	delete cache function.
	* camel/providers/imap/camel-imap-message-cache.h:
	* camel/providers/imap/camel-imap-store.c: Now forget the folder from
	DB.


Modified:
   trunk/camel/providers/imap/ChangeLog
   trunk/camel/providers/imap/camel-imap-message-cache.c
   trunk/camel/providers/imap/camel-imap-message-cache.h
   trunk/camel/providers/imap/camel-imap-store.c

Modified: trunk/camel/providers/imap/camel-imap-message-cache.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-message-cache.c	(original)
+++ trunk/camel/providers/imap/camel-imap-message-cache.c	Thu Jul 31 10:31:51 2008
@@ -197,6 +197,48 @@
 	return cache;
 }
 
+
+/**
+ * camel_imap_message_cache_delete:
+ * @path: directory to use for storage
+ * @ex: a CamelException
+ *
+ * All the files under this directory would be deleted
+ **/
+
+gboolean
+camel_imap_message_cache_delete (const char *path, CamelException *ex)
+{
+	GDir *dir;
+	const char *dname;
+	GError *error = NULL;
+	GPtrArray *deletes;
+	
+	dir = g_dir_open (path, 0, &error);
+	if (!dir) {
+		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+				      _("Could not open cache directory: %s"),
+				      error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	deletes = g_ptr_array_new ();
+	while ((dname = g_dir_read_name (dir)))
+		g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", path, dname)); 
+	
+	g_dir_close (dir);
+
+	while (deletes->len) {
+		g_unlink (deletes->pdata[0]);
+		g_free (deletes->pdata[0]);
+		g_ptr_array_remove_index_fast (deletes, 0);
+	}
+	g_ptr_array_free (deletes, TRUE);
+
+	return TRUE;
+}
+
 /**
  * camel_imap_message_cache_max_uid:
  * @cache: the cache

Modified: trunk/camel/providers/imap/camel-imap-message-cache.h
==============================================================================
--- trunk/camel/providers/imap/camel-imap-message-cache.h	(original)
+++ trunk/camel/providers/imap/camel-imap-message-cache.h	Thu Jul 31 10:31:51 2008
@@ -96,6 +96,8 @@
 					      CamelImapMessageCache *dest,
 					      const char *dest_uid,
 					      CamelException *ex);
+gboolean     camel_imap_message_cache_delete (const char *path, 
+					      CamelException *ex);
 
 /* Standard Camel function */
 CamelType camel_imap_message_cache_get_type (void);

Modified: trunk/camel/providers/imap/camel-imap-store.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-store.c	(original)
+++ trunk/camel/providers/imap/camel-imap-store.c	Thu Jul 31 10:31:51 2008
@@ -1127,9 +1127,7 @@
 static void
 imap_forget_folder (CamelImapStore *imap_store, const char *folder_name, CamelException *ex)
 {
-	CamelFolderSummary *summary;
-	CamelImapMessageCache *cache;
-	char *summary_file, *state_file;
+	char *state_file;
 	char *journal_file;
 	char *folder_dir, *storage_path;
 	CamelFolderInfo *fi;
@@ -1148,37 +1146,8 @@
 		g_free (folder_dir);
 		goto event;
 	}
-	
-	summary_file = g_strdup_printf ("%s/summary", folder_dir);
-	summary = camel_imap_summary_new (NULL, summary_file);
-	if (!summary) {
-		g_free (summary_file);
-		g_free (folder_dir);
-		goto event;
-	}
-	camel_object_unref (summary);
 
-	g_unlink (summary_file);
-	g_free (summary_file);
-
-	summary_file = g_strdup_printf ("%s/summary-meta", folder_dir);
-	summary = camel_imap_summary_new (NULL, summary_file);
-	if (!summary) {
-		g_free (summary_file);
-		g_free (folder_dir);
-		goto event;
-	}
-	
-	cache = camel_imap_message_cache_new (folder_dir, summary, ex);
-	if (cache)
-		camel_imap_message_cache_clear (cache);
-	
-	camel_object_unref (cache);
-	camel_object_unref (summary);
-	
-	g_unlink (summary_file);
-	g_free (summary_file);
-	
+	/* Delete summary and all the data */
 	journal_file = g_strdup_printf ("%s/journal", folder_dir);
 	g_unlink (journal_file);
 	g_free (journal_file);
@@ -1186,6 +1155,9 @@
 	state_file = g_strdup_printf ("%s/cmeta", folder_dir);
 	g_unlink (state_file);
 	g_free (state_file);
+	
+	camel_db_delete_folder (((CamelStore *)imap_store)->cdb, folder_name, ex);
+	camel_imap_message_cache_delete (folder_dir, ex);
 
 	state_file = g_strdup_printf("%s/subfolders", folder_dir);
 	g_rmdir(state_file);



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