im.pidgin.pidgin: 7e3fbc31d04d03b44eec338a8703cd9329136a9a

sadrul at pidgin.im sadrul at pidgin.im
Wed Dec 5 02:35:41 EST 2007


-----------------------------------------------------------------
Revision: 7e3fbc31d04d03b44eec338a8703cd9329136a9a
Ancestor: 81a2d60e6ab943bb88178215dd69843570bae655
Author: sadrul at pidgin.im
Date: 2007-12-05T07:34:11
Branch: im.pidgin.pidgin

Modified files:
        libpurple/plugins/autoaccept.c

ChangeLog: 

Do not overwrite an existing file. Closes #3982.

-------------- next part --------------
============================================================
--- libpurple/plugins/autoaccept.c	a83d8748f89fba538e4ea5a069bcada4ffecc789
+++ libpurple/plugins/autoaccept.c	486791f12dfd236428c003df1625e54450573619
@@ -114,6 +114,8 @@ file_recv_request_cb(PurpleXfer *xfer, g
 		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,9 +124,17 @@ file_recv_request_cb(PurpleXfer *xfer, g
 					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);
 
 				g_free(dirname);


More information about the Commits mailing list