From 9c8e0e983c7775634641281c901953d1b17c32c8 Mon Sep 17 00:00:00 2001 From: Carsten Guenther Date: Wed, 17 Aug 2005 16:00:00 +0000 Subject: Fixes http://bugzilla.gnome.org/show_bug.cgi?id=313555 Only save 2005-08-17 Carsten Guenther Fixes http://bugzilla.gnome.org/show_bug.cgi?id=313555 * gui/dialogs/comp-editor.c: (get_attachment_list): Only save attachment to file if file does not exist yet. svn path=/trunk/; revision=30149 --- calendar/ChangeLog | 7 +++++++ calendar/gui/dialogs/comp-editor.c | 29 ++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 46f746bd59..b33ee7be25 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2005-08-17 Carsten Guenther + + Fixes http://bugzilla.gnome.org/show_bug.cgi?id=313555 + * gui/dialogs/comp-editor.c: + (get_attachment_list): Only save attachment to file + if file does not exist yet. + 2005-08-17 Chenthill Palanisamy Fixes #311904 diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 93b654e3ba..c7178f17fe 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -630,24 +630,27 @@ get_attachment_list (CompEditor *editor) g_free (filename); g_free (safe_fname); - stream = camel_stream_fs_new_with_name((const char *) attach_file_url+7, O_RDWR|O_CREAT|O_TRUNC, 0600); - if (!stream) { - /* TODO handle error conditions */ - g_message ("DEBUG: could not open the file to write\n"); - g_free (attach_file_url); - continue; - } + /* do not overwrite existing files, this will result in truncation */ + if (!g_file_test (attach_file_url+7, G_FILE_TEST_EXISTS)) { + stream = camel_stream_fs_new_with_name((const char *) attach_file_url+7, O_RDWR|O_CREAT|O_TRUNC, 0600); + if (!stream) { + /* TODO handle error conditions */ + g_message ("DEBUG: could not open the file to write\n"); + g_free (attach_file_url); + continue; + } - if (camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) stream) == -1) { - g_free (attach_file_url); + if (camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) stream) == -1) { + g_free (attach_file_url); + camel_stream_close (stream); + camel_object_unref (stream); + g_message ("DEBUG: could not write to file\n"); + } + camel_stream_close (stream); camel_object_unref (stream); - g_message ("DEBUG: could not write to file\n"); } - camel_stream_close (stream); - camel_object_unref (stream); - list = g_slist_append (list, g_strdup (attach_file_url)); g_free (attach_file_url); } -- cgit