From 4a4d051f31809d47dbb382184f8bdbd6d71560ce Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 19 Jun 2015 21:49:05 +0200 Subject: [db,tool] prevent database rebuild when querying version info Reported by /u/ThomasFehige on Github: https://github.com/lualatex/luaotfload/issues/275#issuecomment-113515484 --- src/luaotfload-database.lua | 16 ++++++++++++---- src/luaotfload-tool.lua | 12 ++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index 099c256..1831ca3 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -482,8 +482,8 @@ local fonts_reloaded = false --- limit output when approximate font matching (luaotfload-tool -F) local fuzzy_limit = 1 --- display closest only ---- bool? -> dbobj -load_names = function (dry_run) +--- bool? -> -> bool? -> dbobj option +load_names = function (dry_run, no_rebuild) local starttime = osgettimeofday () local foundname, data = load_lua_file (config.luaotfload.paths.index_path_lua) @@ -519,6 +519,11 @@ load_names = function (dry_run) end end else + if no_rebuild == true then + report ("both", 2, "db", + [[Database does not exist, skipping rebuild though.]]) + return false + end report ("both", 0, "db", [[Font names database not found, generating new one.]]) report ("both", 0, "db", @@ -545,8 +550,11 @@ access_font_index = function () end getmetadata = function () - if not name_index then name_index = load_names() end - return tablefastcopy (name_index.meta) + if not name_index then + name_index = load_names (false, true) + if name_index then return tablefastcopy (name_index.meta) end + end + return false end --- unit -> unit diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 36c23bd..e240e4c 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -288,10 +288,14 @@ local version_msg = function ( ) local var = uname_vars[i] out (" + %8s: %s", var, uname[var]) end - out ("Index: version=%q created=%q modified=%q", - config.luaotfload.status.notes.revision, - meta.created or "ages ago", - meta.modified or "ages ago") + if meta == false then + out("No database metadata available.") + else + out ("Index: version=%q created=%q modified=%q", + config.luaotfload.status.notes.revision, + meta.created or "ages ago", + meta.modified or "ages ago") + end out "" end -- cgit v1.2.3