]> git.wh0rd.org - fontconfig.git/blobdiff - fc-cache/fc-cache.c
Don't check cache file time stamps when cleaning cache dir.
[fontconfig.git] / fc-cache / fc-cache.c
index 0415b54762268222f1acbe6e66336ace1e708a4a..54add90b61e5c87b53eb410b6ac3deaba571c04b 100644 (file)
@@ -201,13 +201,13 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force,
        if (was_valid)
        {
            if (verbose)
-               printf ("skipping, %d fonts, %d dirs\n",
+               printf ("skipping, existing cache is valid: %d fonts, %d dirs\n",
                        FcCacheNumFont (cache), FcCacheNumSubdir (cache));
        }
        else
        {
            if (verbose)
-               printf ("caching, %d fonts, %d dirs\n", 
+               printf ("caching, new cache contents: %d fonts, %d dirs\n", 
                        FcCacheNumFont (cache), FcCacheNumSubdir (cache));
 
            if (!FcDirCacheValid (dir))
@@ -255,7 +255,6 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
     FcBool     ret = FcTrue;
     FcBool     remove;
     FcCache    *cache;
-    struct stat        file_stat;
     struct stat        target_stat;
 
     dir_base = FcStrPlus (dir, (FcChar8 *) "/");
@@ -264,10 +263,11 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
        fprintf (stderr, "%s: out of memory\n", dir);
        return FcFalse;
     }
-    if (access ((char *) dir, W_OK|X_OK) != 0)
+    if (access ((char *) dir, W_OK) != 0)
     {
        if (verbose)
-           printf ("%s: not cleaning unwritable cache directory\n", dir);
+           printf ("%s: not cleaning %s cache directory\n", dir,
+                   access ((char *) dir, F_OK) == 0 ? "unwritable" : "non-existent");
        FcStrFree (dir_base);
        return FcTrue;
     }
@@ -300,29 +300,24 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
            ret = FcFalse;
            break;
        }
-       cache = FcDirCacheLoadFile (file_name, &file_stat);
-       if (!cache)
-       {
-           fprintf (stderr, "%s: invalid cache file: %s\n", dir, ent->d_name);
-           FcStrFree (file_name);
-           ret = FcFalse;
-           continue;
-       }
-       target_dir = FcCacheDir (cache);
        remove = FcFalse;
-       if (stat ((char *) target_dir, &target_stat) < 0)
+       cache = FcDirCacheLoadFile (file_name, NULL);
+       if (!cache)
        {
            if (verbose)
-               printf ("%s: %s: missing directory: %s \n",
-                       dir, ent->d_name, target_dir);
+               printf ("%s: invalid cache file: %s\n", dir, ent->d_name);
            remove = FcTrue;
        }
-       else if (target_stat.st_mtime > file_stat.st_mtime)
+       else
        {
-           if (verbose)
-               printf ("%s: %s: cache outdated: %s\n",
-                       dir, ent->d_name, target_dir);
-           remove = FcTrue;
+           target_dir = FcCacheDir (cache);
+           if (stat ((char *) target_dir, &target_stat) < 0)
+           {
+               if (verbose)
+                   printf ("%s: %s: missing directory: %s \n",
+                           dir, ent->d_name, target_dir);
+               remove = FcTrue;
+           }
        }
        if (remove)
        {