summaryrefslogtreecommitdiff
path: root/src/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-05-14 22:59:50 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2014-05-14 22:59:50 +0200
commitde2ebfd1e897e9bea9aee9ecffe1f146dd457adf (patch)
tree7e8b3037a345152ce93308d6c6419b03b5b1388d /src/luaotfload-database.lua
parent12547b5d6f57b0c8032b1029ed90352f5ac39bdb (diff)
downloadluaotfload-de2ebfd1e897e9bea9aee9ecffe1f146dd457adf.tar.gz
[conf,db,diagnose] reimplement runtime cache path handling as configuration task
Diffstat (limited to 'src/luaotfload-database.lua')
-rw-r--r--src/luaotfload-database.lua40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 4fbf797..d903941 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -119,7 +119,6 @@ local tablefastcopy = table.fastcopy
local tabletofile = table.tofile
local tabletohash = table.tohash
local tableserialize = table.serialize
-local runasscript = caches == nil
--- the font loader namespace is “fonts”, same as in Context
--- we need to put some fallbacks into place for when running
--- as a script
@@ -171,25 +170,24 @@ end
--- XXX this belongs into the initialization file!
local initialize_env = function ()
- if not runasscript then
- local paths = config.luaotfload.paths
- local prefix = getwritablepath (paths.names_dir, "")
- if not prefix then
- luaotfload.error
- ("Impossible to find a suitable writeable cache...")
- else
- prefix = lpegmatch (stripslashes, prefix)
- report ("log", 0, "db",
- "Root cache directory is %s.", prefix)
- end
-
- local lookup_path = names.path.lookups
- local index = names.path.index
- local lookups_file = filejoin (prefix, paths.lookups_file)
- local index_file = filejoin (prefix, paths.index_file)
- lookup_path.lua, lookup_path.luc = make_luanames (lookups_file)
- index.lua, index.luc = make_luanames (index_file)
- else --- running as script, inject some dummies
+ local paths = config.luaotfload.paths
+ local prefix = getwritablepath (paths.names_dir, "")
+ if not prefix then
+ luaotfload.error
+ ("Impossible to find a suitable writeable cache...")
+ else
+ prefix = lpegmatch (stripslashes, prefix)
+ report ("log", 0, "db",
+ "Root cache directory is %s.", prefix)
+ end
+
+ local lookup_path = names.path.lookups
+ local index = names.path.index
+ local lookups_file = filejoin (prefix, paths.lookups_file)
+ local index_file = filejoin (prefix, paths.index_file)
+ lookup_path.lua, lookup_path.luc = make_luanames (lookups_file)
+ index.lua, index.luc = make_luanames (index_file)
+ if not caches then
caches = { }
local dummy_function = function () end
log = { report = dummy_function,
@@ -3252,7 +3250,7 @@ end
--- unit -> bool
save_lookups = function ( )
- local path = names.path.lookups
+ local path = names.path.lookups
local luaname, lucname = path.lua, path.luc
if fileiswritable (luaname) and fileiswritable (lucname) then
tabletofile (luaname, lookup_cache, true)