diff --git a/base b/base index 03693cf2a..66f8b4ae3 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 03693cf2a09e3f3063a220a4944d3232f080a468 +Subproject commit 66f8b4ae3e110da48ad2978cfc362c695eb8717d diff --git a/frontend/apps/filemanager/filemanagermenu.lua b/frontend/apps/filemanager/filemanagermenu.lua index 819a2b8c7..961bbb36f 100644 --- a/frontend/apps/filemanager/filemanagermenu.lua +++ b/frontend/apps/filemanager/filemanagermenu.lua @@ -702,6 +702,13 @@ To: touchmenu_instance:updateItems() end, }) + table.insert(self.menu_items.developer_options.sub_item_table, { + text = _("Dump the fontlist cache"), + callback = function() + local FontList = require("fontlist") + FontList:dumpFontList() + end, + }) self.menu_items.cloud_storage = { text = _("Cloud storage"), diff --git a/frontend/fontlist.lua b/frontend/fontlist.lua index b6ef461eb..3def6df86 100644 --- a/frontend/fontlist.lua +++ b/frontend/fontlist.lua @@ -6,7 +6,6 @@ local Persist = require("persist") local util = require("util") local lfs = require("libs/libkoreader-lfs") local logger = require("logger") -local dbg = require("dbg") local FontList = { fontdir = "./fonts", @@ -168,7 +167,7 @@ function FontList:getFontList() local cache = Persist:new{ path = self.cachedir .. "/fontinfo.dat", - codec = dbg.is_verbose and "dump" or "zstd", + codec = "zstd", } local t, err = cache:load() @@ -197,13 +196,9 @@ function FontList:getFontList() end end - if dbg.is_verbose then - -- when verbose debug is on, always dump the cache in plain text (to inspect the db output) + -- Update the on-disk cache if necessary + if mark.cache_dirty then cache:save(self.fontinfo) - elseif mark.cache_dirty then - -- otherwise dump the db in binary (more compact), and only if something has changed - -- NOTE: The luajit/zstd codecs *ignore* the as_bytecode argument, as they *only* support bytecode ;). - cache:save(self.fontinfo, true) end local names = self.fontnames @@ -212,7 +207,7 @@ function FontList:getFontList() local nlist = names[v.name] or {} assert(v.name) if #nlist == 0 then - logger.dbg("FONTNAMES ADD: ", v.name) + logger.dbg("FontList registered:", v.name) end names[v.name] = nlist table.insert(nlist, v) @@ -223,6 +218,42 @@ function FontList:getFontList() return self.fontlist end +function FontList:dumpFontList() + local dump = require("dump") + + -- FontInfo + local path = self.cachedir .. "/fontinfo_dump.lua" + local f = io.open(path, "w") + if f ~= nil then + os.setlocale('C', 'numeric') + f:write("return ") + f:write(dump(self.fontinfo, nil, true)) + f:close() + else + return + end + + -- FontList + path = self.cachedir .. "/fontlist_dump.lua" + f = io.open(path, "w") + if f ~= nil then + os.setlocale('C', 'numeric') + f:write("return ") + f:write(dump(self.fontlist, nil, true)) + f:close() + else + return + end + + local InfoMessage = require("ui/widget/infomessage") + local UIManager = require("ui/uimanager") + local _ = require("gettext") + local T = require("ffi/util").template + UIManager:show(InfoMessage:new{ + text = T(_("Fontlist data has been dumped in:\n%1"), self.cachedir) + }) +end + -- Try to determine the localized font name function FontList:getLocalizedFontName(file, index) local lang = G_reader_settings:readSetting("language") diff --git a/frontend/ui/data/onetime_migration.lua b/frontend/ui/data/onetime_migration.lua index 0e2e1edd5..509a00703 100644 --- a/frontend/ui/data/onetime_migration.lua +++ b/frontend/ui/data/onetime_migration.lua @@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs") local logger = require("logger") -- Date at which the last migration snippet was added -local CURRENT_MIGRATION_DATE = 20220913 +local CURRENT_MIGRATION_DATE = 20220914 -- Retrieve the date of the previous migration, if any local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0) @@ -436,8 +436,8 @@ if last_migration_date < 20220819 then end -- Fontlist, cache format change (#9513) -if last_migration_date < 20220913 then - logger.info("Performing one-time migration for 20220913") +if last_migration_date < 20220914 then + logger.info("Performing one-time migration for 20220914") local cache_path = DataStorage:getDataDir() .. "/cache/fontlist" local ok, err = os.remove(cache_path .. "/fontinfo.dat")