changeset 21785:3fdd39411e3e

merge of '7e3fbc31d04d03b44eec338a8703cd9329136a9a' and 'cc1c6037df9dd3887248c7bf7627ee45663949ff'
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 05 Dec 2007 11:11:59 +0000
parents 3b1d7caddc27 (diff) 2a47eefca6b3 (current diff)
children 770c384b1803
files
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/autoaccept.c	Wed Dec 05 08:17:15 2007 +0000
+++ b/libpurple/plugins/autoaccept.c	Wed Dec 05 11:11:59 2007 +0000
@@ -114,6 +114,8 @@
 		case FT_ACCEPT:
 			if (ensure_path_exists(pref))
 			{
+				int count = 1;
+				const char *escape;
 				dirname = g_build_filename(pref, purple_normalize(account, xfer->who), NULL);
 
 				if (!ensure_path_exists(dirname))
@@ -122,8 +124,16 @@
 					break;
 				}
 
-				filename = g_build_filename(dirname,
-						purple_escape_filename(xfer->filename), NULL);
+				escape = purple_escape_filename(xfer->filename);
+				filename = g_build_filename(dirname, escape, NULL);
+
+				/* Make sure the file doesn't exist. Do we want some better checking than this? */
+				while (g_file_test(filename, G_FILE_TEST_EXISTS)) {
+					char *file = g_strdup_printf("%s-%d", escape, count++);
+					g_free(filename);
+					filename = g_build_filename(dirname, file, NULL);
+					g_free(file);
+				}
 
 				purple_xfer_request_accepted(xfer, filename);