diff --git a/ChangeLog b/ChangeLog index a69de9d..446d53f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-11-02 Patrick Lam + * src/fccache.c (FcGlobalCacheLoad): + * src/fccfg.c (FcConfigModifiedTime, FcConfigBuildFonts): + * src/fcint.h: + + Declare the global cache of a directory's contents to be stale if + the directory is newer than the (newest) configuration file. + 2005-10-31 Patrick Lam * src/fcint.h: * src/fclist.c (FcListAppend): diff --git a/src/fccache.c b/src/fccache.c index a513652..970a614 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -152,10 +152,12 @@ FcGlobalCacheDestroy (FcGlobalCache *cache) void FcGlobalCacheLoad (FcGlobalCache *cache, FcStrSet *staleDirs, - const FcChar8 *cache_file) + const FcChar8 *cache_file, + FcConfig *config) { char name_buf[8192]; FcGlobalCacheDir *d, *next; + FcFileTime config_time = FcConfigModifiedTime (config); char * current_arch_machine_name; char candidate_arch_machine_name[MACHINE_SIGNATURE_SIZE + 9]; off_t current_arch_start; @@ -191,8 +193,11 @@ FcGlobalCacheLoad (FcGlobalCache *cache, if (!strlen(name_buf)) break; + /* Directory must be older than the global cache file, and + also must be older than the config file. */ if (stat ((char *) name_buf, &dir_stat) < 0 || - dir_stat.st_mtime > cache_stat.st_mtime) + dir_stat.st_mtime > cache_stat.st_mtime || + (config_time.set && dir_stat.st_mtime > config_time.time)) { FcCache md; @@ -553,8 +558,9 @@ FcDirCacheValid (const FcChar8 *dir) * If the directory has been modified more recently than * the cache file, the cache is not valid */ - if (dir_stat.st_mtime - file_stat.st_mtime > 0) + if (dir_stat.st_mtime > file_stat.st_mtime) return FcFalse; + return FcTrue; } diff --git a/src/fccfg.c b/src/fccfg.c index 5d6339f..3781d7b 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -139,11 +139,6 @@ bail0: return 0; } -typedef struct _FcFileTime { - time_t time; - FcBool set; -} FcFileTime; - static FcFileTime FcConfigNewestFile (FcStrSet *files) { @@ -166,6 +161,19 @@ FcConfigNewestFile (FcStrSet *files) return newest; } +FcFileTime +FcConfigModifiedTime (FcConfig *config) +{ + if (!config) + { + FcFileTime v = { 0, FcFalse }; + config = FcConfigGetCurrent (); + if (!config) + return v; + } + return FcConfigNewestFile (config->configFiles); +} + FcBool FcConfigUptoDate (FcConfig *config) { @@ -266,7 +274,7 @@ FcConfigBuildFonts (FcConfig *config) goto bail2; if (config->cache) - FcGlobalCacheLoad (cache, oldDirs, config->cache); + FcGlobalCacheLoad (cache, oldDirs, config->cache, config); cached_fonts = FcCacheRead(config, cache); if (!cached_fonts) diff --git a/src/fcint.h b/src/fcint.h index d13bba6..be43e38 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -406,6 +406,11 @@ struct _FcConfig { extern FcConfig *_fcConfig; +typedef struct _FcFileTime { + time_t time; + FcBool set; +} FcFileTime; + typedef struct _FcCharMap FcCharMap; /* fcblanks.c */ @@ -428,7 +433,8 @@ FcGlobalCacheReadDir (FcFontSet *set, void FcGlobalCacheLoad (FcGlobalCache *cache, FcStrSet *staleDirs, - const FcChar8 *cache_file); + const FcChar8 *cache_file, + FcConfig *config); FcBool FcGlobalCacheUpdate (FcGlobalCache *cache, @@ -514,6 +520,9 @@ FcBool FcConfigAcceptFont (FcConfig *config, const FcPattern *font); +FcFileTime +FcConfigModifiedTime (FcConfig *config); + /* fccharset.c */ FcCharSet * FcCharSetFreeze (FcCharSet *cs);