diff --git a/frontend/apps/filemanager/filemanagermenu.lua b/frontend/apps/filemanager/filemanagermenu.lua index 6768fcacc..14f60309b 100644 --- a/frontend/apps/filemanager/filemanagermenu.lua +++ b/frontend/apps/filemanager/filemanagermenu.lua @@ -378,10 +378,10 @@ To: text = _("Developer options"), sub_item_table = { { - text = _("Clear readers' caches"), + text = _("Clear caches"), callback = function() UIManager:show(ConfirmBox:new{ - text = _("Clear cache/ and cr3cache/ ?"), + text = _("Clear the cache folder?"), ok_callback = function() local DataStorage = require("datastorage") local cachedir = DataStorage:getDataDir() .. "/cache" @@ -389,13 +389,12 @@ To: FFIUtil.purgeDir(cachedir) end lfs.mkdir(cachedir) - -- Also remove from Cache objet references to - -- the cache files we just deleted + -- Also remove from the Cache objet references to the cache files we've just deleted local Cache = require("cache") Cache.cached = {} local InfoMessage = require("ui/widget/infomessage") UIManager:show(InfoMessage:new{ - text = _("Caches cleared. Please exit and restart KOReader."), + text = _("Caches cleared. Please restart KOReader."), }) end, }) diff --git a/frontend/cache.lua b/frontend/cache.lua index f822de880..38ed277c6 100644 --- a/frontend/cache.lua +++ b/frontend/cache.lua @@ -39,6 +39,9 @@ end local cache_path = DataStorage:getDataDir() .. "/cache/" +-- NOTE: Before 2021.04, fontlist used to squat our folder, needlessly polluting our state tracking. +os.remove(cache_path .. "/fontinfo.dat") + --[[ -- return a snapshot of disk cached items for subsequent check --]] diff --git a/frontend/fontlist.lua b/frontend/fontlist.lua index 17d4942e7..30f95cbe0 100644 --- a/frontend/fontlist.lua +++ b/frontend/fontlist.lua @@ -9,6 +9,7 @@ local dbg = require("dbg") local FontList = { fontdir = "./fonts", + cachedir = DataStorage:getDataDir() .. "/cache/fontlist", -- in a subdirectory, so as not to mess w/ the Cache module. fontlist = {}, fontinfo = {}, fontnames = {}, @@ -169,12 +170,15 @@ function FontList:getFontList() if #self.fontlist > 0 then return self.fontlist end local cache = Persist:new{ - path = DataStorage:getDataDir() .. "/cache/fontinfo.dat" + path = self.cachedir .. "/fontinfo.dat" } local t, err = cache:load() if not t then logger.info(cache.path, err, "initializing it") + + -- Create new subdirectory + lfs.mkdir(self.cachedir) end self.fontinfo = t or {}