]> git.wh0rd.org - fontconfig.git/blobdiff - fc-cache/fc-cache.c
Improve error message when fc-cache can't write the cache. Add missing
[fontconfig.git] / fc-cache / fc-cache.c
index 7d01ccf9997f2490e4469fbfd9198be1d07cbca3..7acaafe4a9acdc727836300c573c153d4e6ee8b7 100644 (file)
@@ -93,7 +93,6 @@ usage (char *program)
     exit (1);
 }
 
-#if 0
 static int
 nsubdirs (FcStrSet *set)
 {
@@ -192,7 +191,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
            ret++;
            continue;
        }
-       if (!force && FcDirCacheValid (dir))
+       if (!force && FcDirCacheValid (dir) && FcDirCacheHasCurrentArch (dir))
        {
            if (verbose)
                printf ("skipping, %d fonts, %d dirs\n",
@@ -203,9 +202,16 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
            if (verbose)
                printf ("caching, %d fonts, %d dirs\n", 
                        set->nfont, nsubdirs (subdirs));
+
+            if (!FcDirCacheValid (dir))
+                if (!FcDirCacheUnlink (dir))
+                    ret++;
+
            if (!FcDirSave (set, subdirs, dir))
            {
-               fprintf (stderr, "Can't save cache in \"%s\"\n", dir);
+                if (!ret)
+                    fprintf (stderr, "Caches are currently saved to \"%s\"\n", PKGCACHEDIR);
+               fprintf (stderr, "Can't save cache for \"%s\"\n", dir);
                ret++;
            }
        }
@@ -223,7 +229,6 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
     FcStrListDone (list);
     return ret;
 }
-#endif
 
 int
 main (int argc, char **argv)
@@ -270,20 +275,13 @@ main (int argc, char **argv)
 
     if (systemOnly)
        FcConfigEnableHome (FcFalse);
-    FcCacheForce (FcTrue);
-    /* need to use FcInitLoadConfig when we use dirs */
-    FcInit ();
-    config = FcConfigGetCurrent ();
+    config = FcInitLoadConfig ();
     if (!config)
     {
        fprintf (stderr, "%s: Can't init font config library\n", argv[0]);
        return 1;
     }
 
-    /* We don't yet have per-directory caches. */
-    ret = (FcCacheWrite (config) == FcFalse);
-
-#if 0
     if (argv[i])
     {
        dirs = FcStrSetCreate ();
@@ -308,7 +306,6 @@ main (int argc, char **argv)
     else
        list = FcConfigGetConfigDirs (config);
     ret = scanDirs (list, config, argv[0], force, verbose);
-#endif
     /* 
      * Now we need to sleep a second  (or two, to be extra sure), to make
      * sure that timestamps for changes after this run of fc-cache are later