fix(cache): do a fast check to see if a cached modpath is still valid. find it again otherwise

This commit is contained in:
Folke Lemaitre 2022-12-19 12:21:20 +01:00
parent 1fe43f3e29
commit 32f2b71ff8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 63 additions and 24 deletions

View file

@ -1,6 +1,7 @@
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Handler = require("lazy.core.handler")
local Cache = require("lazy.core.cache")
local M = {}
@ -214,17 +215,4 @@ function M.autoload(modname)
return modname .. " not found in lazy plugins"
end
-- lazy.cache will call this when loading a cached file with modpath set.
---@param modname string
---@param modpath string
function M.check_load(modname, modpath)
-- no need to check anything before init
if M.init_done then
local plugin = require("lazy.core.plugin").find(modpath)
if plugin and not plugin._.loaded then
M.load(plugin, { require = modname })
end
end
end
return M