Skip to content

Commit

Permalink
fix: return nil when fs_stat fails and return nil in module loader
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 2, 2022
1 parent 756b484 commit afcba52
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/lazy/core/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function M.loader(modname)
if entry then
M.check_load(modname, entry.modpath)
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
-- found in cache and up to date
chunk, err = load(entry.chunk --[[@as string]], "@" .. entry.modpath)
Expand Down Expand Up @@ -155,7 +158,8 @@ end

---@return CacheHash?
function M.hash(file)
return uv.fs_stat(file)
local ok, ret = pcall(uv.fs_stat, file)
return ok and ret or nil
end

---@param h1 CacheHash
Expand Down

0 comments on commit afcba52

Please sign in to comment.