提交 c7ec5c3d authored 作者: zhanrongzhen's avatar zhanrongzhen

fix attributes = nil bug

上级 d5c4dd2a
......@@ -112,8 +112,19 @@ http {
ngx.say("<html><body><h1>404 - File Not Found</h1><p>The requested file does not exist.</p></body></html>")
return ngx.exit(ngx.HTTP_NOT_FOUND)
end
if not attributes then
-- 缓存命中但attributes未设置,需重新获取文件属性
attributes, err = lfs.attributes(filepath)
if not attributes then
-- 文件可能已被删除,清除缓存并返回404
cache:delete(key)
ngx.log(ngx.WARN, "File cached as existing but not found: ", filepath)
ngx.header["Content-Type"] = "text/html; charset=utf-8"
ngx.status = ngx.HTTP_NOT_FOUND
ngx.say("<html><body><h1>404 - File Not Found</h1><p>The requested file does not exist.</p></body></html>")
return ngx.exit(ngx.HTTP_NOT_FOUND)
end
end
-- 判断是否有扩展名
local ext = string.match(filename, "%.([^%.]+)$")
local mime_type
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论