[evolution-patches] Fix for 313555: Adding attachments to existing	appointment removes existing attachments (calendar)
- From: "Carsten Guenther" <Carsten Guenther scalix com>
 
- To: evolution-patches lists ximian com
 
- Subject: [evolution-patches] Fix for 313555: Adding attachments to existing	appointment removes existing attachments (calendar)
 
- Date: Mon, 15 Aug 2005 13:22:24 -0700
 
Attached patch checks if the attachment file exists before it creates 
it. If it does it will not overwrite it.
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);
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]