summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-tmp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-tmp.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-tmp.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-tmp.lua b/Master/texmf-dist/tex/context/base/data-tmp.lua
index 5025a8a0ad8..3e109dcfe6d 100644
--- a/Master/texmf-dist/tex/context/base/data-tmp.lua
+++ b/Master/texmf-dist/tex/context/base/data-tmp.lua
@@ -250,6 +250,10 @@ end
caches.getreadablepaths = getreadablepaths
caches.getwritablepath = getwritablepath
+-- this can be tricky as we can have a pre-generated format while at the same time
+-- use e.g. a home path where we have updated file databases and so maybe we need
+-- to check first if we do have a writable one
+
function caches.getfirstreadablefile(filename,...)
local rd = getreadablepaths(...)
for i=1,#rd do
@@ -263,6 +267,28 @@ function caches.getfirstreadablefile(filename,...)
return caches.setfirstwritablefile(filename,...)
end
+-- next time we have an issue, we can test this instead:
+
+function caches.getfirstreadablefile_TEST_ME_FIRST(filename,...)
+ -- check if we have already written once
+ local fullname, path = caches.setfirstwritablefile(filename,...)
+ if is_readable(fullname) then
+ return fullname, path -- , true
+ end
+ -- otherwise search for pregenerated
+ local rd = getreadablepaths(...)
+ for i=1,#rd do
+ local path = rd[i]
+ local fullname = file.join(path,filename)
+ if is_readable(fullname) then
+ usedreadables[i] = true
+ return fullname, path -- , false
+ end
+ end
+ -- else assume new written
+ return fullname, path -- , true
+end
+
function caches.setfirstwritablefile(filename,...)
local wr = getwritablepath(...)
local fullname = file.join(wr,filename)