最近在新的路由器上移植openwrt15.05,发现增加failsafe模块后,web登陆提示如下错误:
/usr/lib/lua/luci/dispatcher.lua:433: Failed to execute function dispatcher target for entry '/'.
The called action terminated with an exception:
/usr/lib/lua/luci/dispatcher.lua:433: Failed to execute function dispatcher target for entry '/failsafe'.
The called action terminated with an exception:
/usr/lib/lua/luci/dispatcher.lua:433: Failed to execute call dispatcher target for entry '/failsafe/flashops'.
The called action terminated with an exception:
/usr/lib/lua/luci/controller/failsafe/failsafe.lua:91: attempt to index upvalue 'fp' (a nil value)
stack traceback:
[C]: in function 'assert'
/usr/lib/lua/luci/dispatcher.lua:433: in function 'dispatch'
/usr/lib/lua/luci/dispatcher.lua:168: in function </usr/lib/lua/luci/dispatcher.lua:167>
打开/usr/lib/lua/luci/controller/failsafe/failsafe.lua文件,发现
local fp
luci.http.setfilehandler(
function(meta, chunk, eof)
if not fp then
if meta and meta.name == "image" then
fp = io.open(image_tmp, "w")
end
end
if chunk then
fp:write(chunk)
end
if eof then
***fp:close()***
end
end
)
此处的fp:cloase()
报错,于是将此处的判断条件修改成:
if eof and fp then
然后测试OK,为了彻底修改,打开openwrt-15.05/openwrt/package/feeds/luci/luci-mod-failsafe/luasrc/controller/failsafe
,将该文件中的if eof then判断条件修改成if eof and fp then,即可。