Patch: add support for purging attachments in maildir folders
- From: Jose Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: add support for purging attachments in maildir folders
- Date: Mon, 17 Sep 2007 17:46:48 +0200
Hi,
This patch adds support for purging attachment in maildir folders, just
as we do for imap folders. For those who don't remember, we have the
tny_msg_rewrite_cache API, used to rewrite a message in local storage
(currently imap cache).
I implemented the same for maildir. In this case we simply write the
new version of the message to "tmp" subfolder, and then move it to the
"cur" folder.
--
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c (revisión: 2773)
+++ libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c (copia de trabajo)
@@ -56,6 +56,7 @@
static void maildir_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, char **appended_uid, CamelException * ex);
static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar * uid, CamelFolderReceiveType type, gint param, CamelException * ex);
+static void maildir_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg);
static void maildir_finalize(CamelObject * object);
@@ -102,6 +103,7 @@
camel_folder_class->append_message = maildir_append_message;
camel_folder_class->get_message = maildir_get_message;
+ camel_folder_class->rewrite_cache = maildir_rewrite_cache;
lclass->create_summary = maildir_create_summary;
}
@@ -282,3 +284,39 @@
return message;
}
+
+static void
+maildir_rewrite_cache (CamelFolder *folder, const char *uid, CamelMimeMessage *msg)
+{
+ CamelLocalFolder *lf = (CamelLocalFolder *) folder;
+ char *name = NULL;
+ CamelStream *output_stream = NULL;
+
+ CamelMessageInfo *mi;
+ CamelMaildirMessageInfo *mdi;
+ char *dest = NULL;
+
+ /* write it out to tmp, use the uid we got from the summary */
+ name = g_strdup_printf ("%s/tmp/%s", lf->folder_path, uid);
+ output_stream = camel_stream_fs_new_with_name (name, O_WRONLY|O_CREAT, 0600);
+ if (output_stream == NULL)
+ goto fail_write;
+
+ if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *)msg, output_stream) == -1
+ || camel_stream_close (output_stream) == -1)
+ goto fail_write;
+
+ /* now move from tmp to cur (bypass new, does it matter?) */
+ dest = g_strdup_printf("%s/cur/%s", lf->folder_path, uid);
+ if (rename (name, dest) == -1)
+ goto fail_write;
+
+ g_free (dest);
+ g_free (name);
+
+ return;
+
+ fail_write:
+ g_free (name);
+ g_free (dest);
+}
Index: ChangeLog
===================================================================
--- ChangeLog (revisión: 2773)
+++ ChangeLog (copia de trabajo)
@@ -1,3 +1,9 @@
+2007-09-17 Jose Dapena Paz <jdapena igalia com>
+
+ * libtinymail-camel/camel-lite/camel/providers/local/camel-maildir-folder.c:
+ Add implementation of method rewrite_cache for maildir,
+ so that we can implement also purge in maildir.
+
2007-09-17 Mark Doffman <mark doffman codethink co uk>
* /bindings/python/gendefs/defsgen.py:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]