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.
+
+2008-07-31 Srinivasa Ragavan <sragavan@novell.com>
+
* camel/providers/imap/camel-imap-message-cache.c: Fix delete cache
code, when the summary is deleted.
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
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);
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;
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);
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);