summaryrefslogtreecommitdiff
path: root/fc-cache
diff options
context:
space:
mode:
authorKeith Packard <keithp@koto.keithp.com>2007-10-18 05:05:59 -0700
committerKeith Packard <keithp@koto.keithp.com>2007-10-18 05:07:29 -0700
commit2a3e3c442de4c675e28e754dea0fe2f7f0686ade (patch)
treebc57f569bec5a637fe45791c770500399a49f594 /fc-cache
parent238489030a64fa883f8f9fc3d73247b7f7257899 (diff)
Have fc-cache remove invalid cache files from cache directories.
Old cache file versions, or corrupted cache files should be removed when cleaning cache directories with fc-cache. This only affects filenames which match the fontconfig cache file format, so other files will be left alone.
Diffstat (limited to 'fc-cache')
-rw-r--r--fc-cache/fc-cache.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index dda40c19..b4d49885 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -301,29 +301,31 @@ cleanCacheDirectory (FcConfig *config, FcChar8 *dir, FcBool verbose)
ret = FcFalse;
break;
}
+ remove = FcFalse;
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)
- {
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;
+ }
+ else if (target_stat.st_mtime > file_stat.st_mtime)
+ {
+ if (verbose)
+ printf ("%s: %s: cache outdated: %s\n",
+ dir, ent->d_name, target_dir);
+ remove = FcTrue;
+ }
}
if (remove)
{