Patch: fix for fc-cache with relative path

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

 



Hi,

the new cache location code has introduced new bugs in fontconfig :
-when using fc-cache . in a directory, the string used to generate
md5sum key is always "./fonts.cache-2" which will collide if the same
command is run in several directories.
-a similar problem happen when using : fc-cache /foo/bar and
fc-cache /foo/bar/ : strings used to generate md5sum are not the same,
resulting in different cache.

The attached patch fixes the issue.

I've also found other problems but I haven't fixed them (help welcome) :
-if you have a directory containing fonts.cache-2 file which are not
up-to-date but cache in /var/cache is up to date, running fc-cache will
not remove those fonts.cache-2, even with fc-cache -f. I tried to force
removal of old cache when using -f but doing so would break multiarch
cache (for instance, we run fc-cache -f when upgrading fontconfig
package, to be sure cache is coherent after a fontconfig upgrade).
-in some directories containing only ttf fonts, running fc-cache -v
again and again always regenerate the cache (which is strange, since the
directory was not modified at all).
-this last bug is causing huge delays when starting applications for the
first time after running fc-cache as root, since cache is detected as
dirty and fontconfig regenerates it for the user (and on my test system,
I have two big chinese fonts of 20MB  and 16MB ...).

-- 
Frederic Crozat <fcrozat@xxxxxxxxxxxx>
Mandriva
--- fontconfig-2.3.92/fc-cache/fc-cache.c.realpath	2006-01-04 16:15:45.000000000 +0100
+++ fontconfig-2.3.92/fc-cache/fc-cache.c	2006-01-04 16:20:24.000000000 +0100
@@ -23,6 +23,7 @@
  */
 
 #include <fontconfig/fontconfig.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -282,6 +283,8 @@
 
     if (argv[i])
     {
+	char resolved_path[PATH_MAX];
+
 	dirs = FcStrSetCreate ();
 	if (!dirs)
 	{
@@ -291,9 +294,14 @@
 	}
 	while (argv[i])
 	{
-	    if (!FcStrSetAdd (dirs, (FcChar8 *) argv[i]))
+	    if (realpath(argv[i], resolved_path) == NULL) {
+		fprintf (stderr, "%s: Can't resolve path %s\n", argv[0], argv[i]);
+		return 1;
+	    }
+	    
+	    if (!FcStrSetAdd (dirs, (FcChar8 *) resolved_path))
 	    {
-		fprintf (stderr, "%s: Can't add directory\n", argv[0]);
+		fprintf (stderr, "%s: Can't add directory %s\n", argv[0], resolved_path);
 		return 1;
 	    }
 	    i++;
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux