[evolution] Bug 667576 - Junk between messages after saving an mbox file
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 667576 - Junk between messages after saving an mbox file
- Date: Thu, 2 Feb 2012 14:20:34 +0000 (UTC)
commit df3495a6ec99d53beeaac6b9a2fde8dfd356c439
Author: James Bottomley <jejbev hansenpartnership com>
Date: Thu Feb 2 08:44:59 2012 -0500
Bug 667576 - Junk between messages after saving an mbox file
libemail-engine/e-mail-folder-utils.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c
index 25754f4..7819cb5 100644
--- a/libemail-engine/e-mail-folder-utils.c
+++ b/libemail-engine/e-mail-folder-utils.c
@@ -1164,8 +1164,8 @@ e_mail_folder_save_messages_sync (CamelFolder *folder,
GError **error)
{
GFileOutputStream *file_output_stream;
+ CamelStream *base_stream = NULL;
GByteArray *byte_array;
- CamelStream *base_stream;
gboolean success = TRUE;
guint ii;
@@ -1194,9 +1194,7 @@ e_mail_folder_save_messages_sync (CamelFolder *folder,
return FALSE;
}
- /* CamelStreamMem takes ownership of the GByteArray. */
byte_array = g_byte_array_new ();
- base_stream = camel_stream_mem_new_with_byte_array (byte_array);
for (ii = 0; ii < message_uids->len; ii++) {
CamelMimeMessage *message;
@@ -1207,6 +1205,17 @@ e_mail_folder_save_messages_sync (CamelFolder *folder,
gint percent;
gint retval;
+ if (base_stream != NULL)
+ g_object_unref (base_stream);
+
+ /* CamelStreamMem does NOT take ownership of the byte
+ * array when set with camel_stream_mem_set_byte_array().
+ * This allows us to reuse the same memory slab for each
+ * message, which is slightly more efficient. */
+ base_stream = camel_stream_mem_new ();
+ camel_stream_mem_set_byte_array (
+ CAMEL_STREAM_MEM (base_stream), byte_array);
+
uid = g_ptr_array_index (message_uids, ii);
message = camel_folder_get_message_sync (
@@ -1264,18 +1273,19 @@ e_mail_folder_save_messages_sync (CamelFolder *folder,
percent = ((ii + 1) * 100) / message_uids->len;
camel_operation_progress (cancellable, percent);
- /* Flush the buffer for the next message.
- * For memory streams this never fails. */
- g_seekable_seek (
- G_SEEKABLE (base_stream),
- 0, G_SEEK_SET, NULL, NULL);
+ /* Reset the byte array for the next message. */
+ g_byte_array_set_size (byte_array, 0);
g_object_unref (message);
}
exit:
+ if (base_stream != NULL)
+ g_object_unref (base_stream);
+
+ g_byte_array_free (byte_array, TRUE);
+
g_object_unref (file_output_stream);
- g_object_unref (base_stream);
camel_operation_pop_message (cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]