summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload-database.lua35
-rwxr-xr-xluaotfload-tool.lua11
2 files changed, 28 insertions, 18 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 224fa61..720554b 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -274,7 +274,10 @@ load_names = function ( )
[[Font names database not found, generating new one.
This can take several minutes; please be patient.]])
data = update_names(fontnames_init(false))
- save_names(data)
+ local success = save_names(data)
+ if not success then
+ report("both", 0, "db", "Database creation unsuccessful.")
+ end
end
fonts_loaded = true
return data
@@ -443,7 +446,10 @@ resolve_cached = function (_, _, specification)
--- TODO this should trigger a save only once the
--- document is compiled (finish_pdffile callback?)
report("both", 5, "cache", "saving updated cache")
- save_lookups()
+ local success = save_lookups()
+ if not success then --- sad, but not critical
+ report("both", 0, "cache", "could not write to cache")
+ end
return filename, subfont, true
end
@@ -675,9 +681,12 @@ end --- resolve()
reload_db = function (why, caller, ...)
report("both", 1, "db", "reload initiated; reason: ā€œ%sā€", why)
names.data = update_names()
- save_names()
- fonts_reloaded = true
- return caller(...)
+ local success = save_names()
+ if success then
+ fonts_reloaded = true
+ return caller(...)
+ end
+ report("both", 0, "db", "Database update unsuccessful.")
end
--- string -> string -> int
@@ -1457,7 +1466,7 @@ end
--- file. As we update it after every single addition this saves us
--- quite some time.
---- unit -> string
+--- unit -> bool
save_lookups = function ( )
---- this is boilerplate and should be refactored into something
---- usable by both the db and the cache writers
@@ -1471,19 +1480,19 @@ save_lookups = function ( )
os.remove(lucname)
caches.compile(lookups, luaname, lucname)
report("both", 3, "cache", "Lookup cache saved")
- return names.path.lookup_path
+ return true
end
end
end
report("info", 0, "cache", "Could not write lookup cache")
- return nil
+ return false
end
--- save_names() is usually called without the argument
---- dbobj -> unit
+--- dbobj? -> bool
save_names = function (fontnames)
if not fontnames then fontnames = names.data end
- local path = ensure_names_path()
+ local path = ensure_names_path()
if fileiswritable(path) then
local luaname, lucname = make_name(names.path.path)
if luaname then
@@ -1492,13 +1501,13 @@ save_names = function (fontnames)
if lucname and type(caches.compile) == "function" then
os.remove(lucname)
caches.compile(fontnames, luaname, lucname)
- report("info", 0, "db", "Font names database saved")
- return names.path.path
+ report("info", 1, "db", "Font names database saved")
+ return true
end
end
end
report("both", 0, "db", "Failed to save names database")
- return nil
+ return false
end
scan_external_dir = function (dir)
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index 2c525d9..93d6acf 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -259,6 +259,7 @@ actions.loglevel = function (job)
logs.set_loglevel(job.log_level)
logs.names_report("info", 3, "util",
"setting log level", "%d", job.log_level)
+ logs.names_report("log", 0, "util", "lua=%s", _VERSION)
return true, true
end
@@ -277,8 +278,8 @@ actions.generate = function (job)
fontnames = names.update(fontnames, job.force_reload)
logs.names_report("info", 2, "db",
"Fonts in the database: %i", #fontnames.mappings)
- savedname = names.save(fontnames)
- if savedname then --- FIXME have names.save return bool
+ local success = names.save(fontnames)
+ if success then
return true, true
end
return false, false
@@ -287,9 +288,9 @@ end
actions.flush = function (job)
local success, lookups = names.flush_cache()
if success then
- local savedname = names.save_lookups()
- logs.names_report("info", 2, "cache", "Cache emptied")
- if savedname then
+ local success = names.save_lookups()
+ if success then
+ logs.names_report("info", 2, "cache", "Cache emptied")
return true, true
end
end