rhythmbox r6286 - in trunk: . plugins/ipod



Author: teuf
Date: Sun Apr 12 07:56:35 2009
New Revision: 6286
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6286&view=rev

Log:
2009-04-12  Christophe Fergeau  <cfergeau mandriva com>

	patch by: Robert Ancell  <robert ancell gmail com>

	* plugins/ipod/rb-ipod-source.c: try harder to build a unique
	filename when writing to the iPod by adding a random suffix to
	filenames when we have to truncate them. Fixes bug #570600.

Modified:
   trunk/ChangeLog
   trunk/plugins/ipod/rb-ipod-source.c

Modified: trunk/plugins/ipod/rb-ipod-source.c
==============================================================================
--- trunk/plugins/ipod/rb-ipod-source.c	(original)
+++ trunk/plugins/ipod/rb-ipod-source.c	Sun Apr 12 07:56:35 2009
@@ -1329,15 +1329,22 @@
 	g_free (dirname);
 
 	if (strlen (result) >= IPOD_MAX_PATH_LEN) {
-		char *ext;
+		char *ext, *suffix;
 
 		ext = strrchr (result, '.');
 		if (ext == NULL) {
+			suffix = result + IPOD_MAX_PATH_LEN - 4;
 			result [IPOD_MAX_PATH_LEN - 1] = '\0';
 		} else {
+			suffix = result + IPOD_MAX_PATH_LEN - 4 - strlen(ext);
 			memmove (&result[IPOD_MAX_PATH_LEN - strlen (ext) - 1] ,
 				 ext, strlen (ext) + 1);
 		}
+
+		/* Add suffix to reduce the chance of a name collision with truncated name */
+		suffix[0] = '~';
+		suffix[1] = 'A' + g_random_int_range (0, 26);
+		suffix[2] = 'A' + g_random_int_range (0, 26);
 	}
 
 	tmp = g_build_filename (mount_point, result, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]