fix(cache): dont keep invalid entries in the cache (cleanup)

This commit is contained in:
Folke Lemaitre 2023-01-10 08:42:51 +01:00
parent d3a963d51c
commit 9fa62ea8ea
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 8 additions and 3 deletions

View File

@ -144,9 +144,14 @@ function M.loader(modname)
local entry = M.cache[modname]
local chunk, err
if entry and M.check_path(modname, entry.modpath) then
M.stats.find.total = M.stats.find.total + 1
chunk, err = M.load(modname, entry.modpath)
if entry then
if M.check_path(modname, entry.modpath) then
M.stats.find.total = M.stats.find.total + 1
chunk, err = M.load(modname, entry.modpath)
else
M.cache[modname] = nil
M.dirty = true
end
end
if not chunk then
-- find the modpath and load the module