blob: 73c619f41d6feaa0a95d88758720a49cbf65bc3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
% Update the ConTeXt filename cache if the system ls-R files are modified
\startluacode
local addsuffix = file.addsuffix
local attributes = lfs.attributes
local difftime = os.difftime
local file_join = file.join
local getfirstreadablefile = caches.getfirstreadablefile
local gethashes = resolvers.gethashes
local hashed = caches.hashed
local ipairs = ipairs
local pcall = pcall
local resolve = resolvers.resolve
local time = os.time
local totime = utilities.parsers.totime
local stale = false
for _, tree in ipairs(gethashes()) do
local lsR_path = file_join(resolve(tree.name), "ls-R")
local lsR_time = attributes(lsR_path, "modification")
local hash = hashed(tree.name)
local path = getfirstreadablefile(addsuffix(hash, "lua"), "trees")
local state, blob = pcall(loadfile, path)
local hash_time
if blob then
local data = blob()
if data then
hash_time = time(totime(data.date .. " " .. data.time))
end
end
if lsR_time and hash_time and difftime(lsR_time, hash_time) > 0 then
stale = true
end
end
if stale then
resolvers.renewcache()
resolvers.load()
end
\stopluacode
% Set the default paper size
\readsysfile{context-papersize.tex}{}{}
|