talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 2fd9c08068b2500ca860d0c6dd267cafc283970b
parent 72cea9e601fd6801ec14a4293cf10cf3ccf7ea98
Author: Colin Leroy <colin@colino.net>
Date:   Mon,  5 May 2008 07:20:29 +0000

2008-05-05 [colin]	3.4.0cvs24

	* src/mimeview.c
		Don't overwrite temporary files with same
		name when drag and dropping. Fixes bug 1599,
		'attach multiple files with the same name from
		one mail to another'

Diffstat:
MChangeLog | 8++++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/mimeview.c | 25+++++++++++++++++++++++++
4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-05 [colin] 3.4.0cvs24 + + * src/mimeview.c + Don't overwrite temporary files with same + name when drag and dropping. Fixes bug 1599, + 'attach multiple files with the same name from + one mail to another' + 2008-05-04 [paul] 3.4.0cvs23 * src/compose.c diff --git a/PATCHSETS b/PATCHSETS @@ -3319,3 +3319,4 @@ ( cvs diff -u -r 1.43.2.96 -r 1.43.2.97 src/toolbar.c; ) > 3.4.0cvs21.patchset ( cvs diff -u -r 1.58.2.38 -r 1.58.2.39 po/de.po; ) > 3.4.0cvs22.patchset ( cvs diff -u -r 1.382.2.446 -r 1.382.2.447 src/compose.c; cvs diff -u -r 1.204.2.167 -r 1.204.2.168 src/prefs_common.c; ) > 3.4.0cvs23.patchset +( cvs diff -u -r 1.83.2.128 -r 1.83.2.129 src/mimeview.c; ) > 3.4.0cvs24.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=4 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=23 +EXTRA_VERSION=24 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/mimeview.c b/src/mimeview.c @@ -1431,6 +1431,7 @@ static void mimeview_drag_data_get(GtkWidget *widget, gchar *filename = NULL, *uriname, *tmp; MimeInfo *partinfo; gint err; + gint count = 0; if (!mimeview->opened) return; if (!mimeview->file) return; @@ -1484,6 +1485,30 @@ static void mimeview_drag_data_get(GtkWidget *widget, filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S, tmp, NULL); +check_new_file: + if (is_file_exist(filename)) { + gchar *ext = NULL; + gchar *prefix = NULL; + gchar *new_name = NULL; + if (strrchr(tmp, '.')) { + prefix = g_strdup(tmp); + ext = g_strdup(strrchr(tmp, '.')); + *(strrchr(prefix, '.')) = '\0'; + } else { + prefix = g_strdup(tmp); + ext = g_strdup(""); + } + count++; + new_name = g_strdup_printf("%s.%d%s", prefix, count, ext); + g_free(prefix); + g_free(ext); + g_free(filename); + filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S, + new_name, NULL); + g_free(new_name); + goto check_new_file; + } + g_free(tmp); if ((err = procmime_get_part(filename, partinfo)) < 0)