summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2017-07-31 10:06:27 +0100
committerAkira TAGOH <akira@tagoh.org>2018-05-16 17:23:58 +0900
commitd443d611350945a8e65b3f8363440b9d814a1df5 (patch)
treecd66c6e8f201bf623eb0ce8b1a1c4f3137f87990
parentf098adac54ab86b75a38f2d23fa706a1348f55ba (diff)
Add APIs to manage the cache updates on loadingdisable-auto-update
-rw-r--r--doc/fcconfig.fncs20
-rw-r--r--fontconfig/fontconfig.h6
-rw-r--r--src/fccache.c2
-rw-r--r--src/fccfg.c30
-rw-r--r--src/fcinit.c5
-rw-r--r--src/fcint.h1
6 files changed, 64 insertions, 0 deletions
diff --git a/doc/fcconfig.fncs b/doc/fcconfig.fncs
index de7a5d79..7424ffa2 100644
--- a/doc/fcconfig.fncs
+++ b/doc/fcconfig.fncs
@@ -445,3 +445,23 @@ for 'iter' where points to current configuration file information.
If the iterator is invalid, FcFalse is returned.
@SINCE@ 2.12.91
@@
+
+@RET@ FcBool
+@FUNC@ FcConfigEnableCacheUpdateOnLoad
+@TYPE1@ FcConfig * @ARG1@ config
+@TYPE2@ FcBool @ARG2@ enable
+@PURPOSE@ controls the cache updates on loading
+@DESC@
+If <parameter>enable</parameter> is set to FcFalse, caches won't be updated
+even if it is supposed to be. this API is to manage the cache updates on loading.
+@SINCE@ 2.13.0
+@@
+
+@RET@ FcBool
+@FUNC@ FcConfigIsCacheUpdatedOnLoad
+@TYPE1@ FcConfig * @ARG1@ config
+@PURPOSE@ Query the enablement of the cache updates on loading
+@DESC@
+Returns whether fontconfig is going to update caches on loading if needed.
+@SINCE@ 2.13.0
+@@
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 5c04219e..6495d2d2 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -484,6 +484,12 @@ FcConfigFileInfoIterGet (FcConfig *config,
FcChar8 **description,
FcBool *enabled);
+FcPublic FcBool
+FcConfigEnableCacheUpdateOnLoad (FcConfig *config, FcBool enable);
+
+FcPublic FcBool
+FcConfigIsCacheUpdatedOnLoad (FcConfig *config);
+
/* fccharset.c */
FcPublic FcCharSet*
FcCharSetCreate (void);
diff --git a/src/fccache.c b/src/fccache.c
index 27b12827..049d8e83 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -746,6 +746,8 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
struct stat dir_static;
FcBool fnano = FcTrue;
+ if (!FcConfigIsCacheUpdatedOnLoad (config))
+ return FcTrue;
if (!dir_stat)
{
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
diff --git a/src/fccfg.c b/src/fccfg.c
index e966e57b..128d9e1d 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -153,6 +153,8 @@ FcConfigCreate (void)
FcRefInit (&config->ref, 1);
+ config->update_on_load = FcTrue;
+
return config;
bail10:
@@ -2653,6 +2655,34 @@ FcConfigFileInfoIterGet (FcConfig *config,
return FcTrue;
}
+FcBool
+FcConfigEnableCacheUpdateOnLoad (FcConfig *config, FcBool enable)
+{
+ FcBool ret = FcTrue;
+
+ if (!config)
+ {
+ config = FcConfigGetCurrent ();
+ if (!config)
+ return ret;
+ }
+ ret = config->update_on_load;
+ config->update_on_load = enable;
+ return ret;
+}
+
+FcBool
+FcConfigIsCacheUpdatedOnLoad (FcConfig *config)
+{
+ if (!config)
+ {
+ config = FcConfigGetCurrent ();
+ if (!config)
+ return FcTrue;
+ }
+ return config->update_on_load;
+}
+
#define __fccfg__
#include "fcaliastail.h"
#undef __fccfg__
diff --git a/src/fcinit.c b/src/fcinit.c
index 5831a196..a0f65d59 100644
--- a/src/fcinit.c
+++ b/src/fcinit.c
@@ -235,6 +235,11 @@ FcInitBringUptoDate (void)
if (!config)
return FcFalse;
/*
+ * don't do anything if the cache updates on load is disabled.
+ */
+ if (!FcConfigIsCacheUpdatedOnLoad (config))
+ return FcFalse;
+ /*
* rescanInterval == 0 disables automatic up to date
*/
if (config->rescanInterval == 0)
diff --git a/src/fcint.h b/src/fcint.h
index a402ca27..a7cd1922 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -567,6 +567,7 @@ struct _FcConfig {
FcPtrList *rulesetList; /* List of rulesets being installed */
FcHashTable *uuid_table; /* UUID table for cachedirs */
FcHashTable *alias_table; /* alias table for cachedirs */
+ FcBool update_on_load; /* whether update caches on load */
};
typedef struct _FcFileTime {