Re: [evolution-patches] Fix for 313555: Adding attachments to existing appointment removes existing attachments (calendar)
- From: Not Zed <notzed ximian com>
- To: Carsten Guenther <Carsten Guenther scalix com>
- Cc: evolution-patches lists ximian com
- Subject: Re: [evolution-patches] Fix for 313555: Adding attachments to existing appointment removes existing attachments (calendar)
- Date: Thu, 18 Aug 2005 12:25:01 +0800
Could use O_EXCL
On Tue, 2005-08-16 at 23:41 -0700, Carsten Guenther wrote:
> Attached patch checks if the attachment file exists before it creates
> it. If it does it will not overwrite it.
>
> OK to commit?
>
> Carsten
>
> Index: comp-editor.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor.c,v
> retrieving revision 1.147
> diff -u -p -r1.147 comp-editor.c
> --- comp-editor.c 12 Aug 2005 21:19:52 -0000 1.147
> +++ comp-editor.c 15 Aug 2005 20:19:58 -0000
> @@ -630,23 +630,26 @@ 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_exists (attach_file_url+7)) {
> + 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);
>
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
--
adfa(evolution-2.4:20087): gtkhtml-WARNING **: cannot find icon:
'stock_insert-url' in gnome
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]