]> git.wh0rd.org - fontconfig.git/commitdiff
Declare the global cache of a directory's contents to be stale if the
authorPatrick Lam <plam@MIT.EDU>
Wed, 2 Nov 2005 06:29:14 +0000 (06:29 +0000)
committerPatrick Lam <plam@MIT.EDU>
Wed, 2 Nov 2005 06:29:14 +0000 (06:29 +0000)
    directory is newer than the (newest) configuration file. S:
    ----------------------------------------------------------------------

ChangeLog
src/fccache.c
src/fccfg.c
src/fcint.h

index a69de9d2daa58853def6351563b44f96e737b710..446d53f803e8fa7748741f9b244145f214e50f43 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
        * src/fcint.h:
        * src/fclist.c (FcListAppend):
index a513652025d4ad43c6d050b1d4c2112161a7cfc0..970a614f5956c9b367aac15d37add7b2612946c7 100644 (file)
@@ -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;
 }
 
index 5d6339f65af9102b828000ece797127dffa5bb2d..3781d7b4a8633411a4691bbdd8eff153e7853d41 100644 (file)
@@ -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)
index d13bba6a0f13d92fb4d5c984515cc5a8425d4c4d..be43e380a07f8b0766fdefeb8bc730db86d7b052 100644 (file)
@@ -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);