mirror of https://github.com/folke/lazy.nvim.git
fix: return nil when `fs_stat` fails and return nil in module loader
This commit is contained in:
parent
756b4849d9
commit
afcba52b1a
|
@ -65,7 +65,10 @@ function M.loader(modname)
|
||||||
if entry then
|
if entry then
|
||||||
M.check_load(modname, entry.modpath)
|
M.check_load(modname, entry.modpath)
|
||||||
entry.used = os.time()
|
entry.used = os.time()
|
||||||
local hash = assert(M.hash(entry.modpath))
|
local hash = M.hash(entry.modpath)
|
||||||
|
if not hash then
|
||||||
|
return
|
||||||
|
end
|
||||||
if M.eq(entry.hash, hash) then
|
if M.eq(entry.hash, hash) then
|
||||||
-- found in cache and up to date
|
-- found in cache and up to date
|
||||||
chunk, err = load(entry.chunk --[[@as string]], "@" .. entry.modpath)
|
chunk, err = load(entry.chunk --[[@as string]], "@" .. entry.modpath)
|
||||||
|
@ -155,7 +158,8 @@ end
|
||||||
|
|
||||||
---@return CacheHash?
|
---@return CacheHash?
|
||||||
function M.hash(file)
|
function M.hash(file)
|
||||||
return uv.fs_stat(file)
|
local ok, ret = pcall(uv.fs_stat, file)
|
||||||
|
return ok and ret or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param h1 CacheHash
|
---@param h1 CacheHash
|
||||||
|
|
Loading…
Reference in New Issue