Declare the global cache of a directory's contents to be stale if the

directory is newer than the (newest) configuration file. S:
    ----------------------------------------------------------------------
This commit is contained in:
Patrick Lam 2005-11-02 06:29:14 +00:00
parent 793154ed8d
commit 2b25f00c50
4 changed files with 41 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2005-11-02 Patrick Lam <plam@mit.edu>
* 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 <plam@mit.edu> 2005-10-31 Patrick Lam <plam@mit.edu>
* src/fcint.h: * src/fcint.h:
* src/fclist.c (FcListAppend): * src/fclist.c (FcListAppend):

View File

@ -152,10 +152,12 @@ FcGlobalCacheDestroy (FcGlobalCache *cache)
void void
FcGlobalCacheLoad (FcGlobalCache *cache, FcGlobalCacheLoad (FcGlobalCache *cache,
FcStrSet *staleDirs, FcStrSet *staleDirs,
const FcChar8 *cache_file) const FcChar8 *cache_file,
FcConfig *config)
{ {
char name_buf[8192]; char name_buf[8192];
FcGlobalCacheDir *d, *next; FcGlobalCacheDir *d, *next;
FcFileTime config_time = FcConfigModifiedTime (config);
char * current_arch_machine_name; char * current_arch_machine_name;
char candidate_arch_machine_name[MACHINE_SIGNATURE_SIZE + 9]; char candidate_arch_machine_name[MACHINE_SIGNATURE_SIZE + 9];
off_t current_arch_start; off_t current_arch_start;
@ -191,8 +193,11 @@ FcGlobalCacheLoad (FcGlobalCache *cache,
if (!strlen(name_buf)) if (!strlen(name_buf))
break; 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 || 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; FcCache md;
@ -553,8 +558,9 @@ FcDirCacheValid (const FcChar8 *dir)
* If the directory has been modified more recently than * If the directory has been modified more recently than
* the cache file, the cache is not valid * 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 FcFalse;
return FcTrue; return FcTrue;
} }

View File

@ -139,11 +139,6 @@ bail0:
return 0; return 0;
} }
typedef struct _FcFileTime {
time_t time;
FcBool set;
} FcFileTime;
static FcFileTime static FcFileTime
FcConfigNewestFile (FcStrSet *files) FcConfigNewestFile (FcStrSet *files)
{ {
@ -166,6 +161,19 @@ FcConfigNewestFile (FcStrSet *files)
return newest; return newest;
} }
FcFileTime
FcConfigModifiedTime (FcConfig *config)
{
if (!config)
{
FcFileTime v = { 0, FcFalse };
config = FcConfigGetCurrent ();
if (!config)
return v;
}
return FcConfigNewestFile (config->configFiles);
}
FcBool FcBool
FcConfigUptoDate (FcConfig *config) FcConfigUptoDate (FcConfig *config)
{ {
@ -266,7 +274,7 @@ FcConfigBuildFonts (FcConfig *config)
goto bail2; goto bail2;
if (config->cache) if (config->cache)
FcGlobalCacheLoad (cache, oldDirs, config->cache); FcGlobalCacheLoad (cache, oldDirs, config->cache, config);
cached_fonts = FcCacheRead(config, cache); cached_fonts = FcCacheRead(config, cache);
if (!cached_fonts) if (!cached_fonts)

View File

@ -406,6 +406,11 @@ struct _FcConfig {
extern FcConfig *_fcConfig; extern FcConfig *_fcConfig;
typedef struct _FcFileTime {
time_t time;
FcBool set;
} FcFileTime;
typedef struct _FcCharMap FcCharMap; typedef struct _FcCharMap FcCharMap;
/* fcblanks.c */ /* fcblanks.c */
@ -428,7 +433,8 @@ FcGlobalCacheReadDir (FcFontSet *set,
void void
FcGlobalCacheLoad (FcGlobalCache *cache, FcGlobalCacheLoad (FcGlobalCache *cache,
FcStrSet *staleDirs, FcStrSet *staleDirs,
const FcChar8 *cache_file); const FcChar8 *cache_file,
FcConfig *config);
FcBool FcBool
FcGlobalCacheUpdate (FcGlobalCache *cache, FcGlobalCacheUpdate (FcGlobalCache *cache,
@ -514,6 +520,9 @@ FcBool
FcConfigAcceptFont (FcConfig *config, FcConfigAcceptFont (FcConfig *config,
const FcPattern *font); const FcPattern *font);
FcFileTime
FcConfigModifiedTime (FcConfig *config);
/* fccharset.c */ /* fccharset.c */
FcCharSet * FcCharSet *
FcCharSetFreeze (FcCharSet *cs); FcCharSetFreeze (FcCharSet *cs);