diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-14 15:33:16 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-14 15:33:16 +0000 |
commit | 180dbe580b351d06a6d014cdb3c3f20d6ea90af9 (patch) | |
tree | 7fbb7b751e2ed3d2ffd9a72e5e86738c25e443c3 /applications/luci-vnstat/luasrc/view | |
parent | c499b8375630bc8471964f7904f5654b5822541c (diff) |
applications/luci-vnstat: fix crash if database dir does not exist
Diffstat (limited to 'applications/luci-vnstat/luasrc/view')
-rw-r--r-- | applications/luci-vnstat/luasrc/view/vnstat.htm | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/applications/luci-vnstat/luasrc/view/vnstat.htm b/applications/luci-vnstat/luasrc/view/vnstat.htm index 91fd332237..d67f9b3be7 100644 --- a/applications/luci-vnstat/luasrc/view/vnstat.htm +++ b/applications/luci-vnstat/luasrc/view/vnstat.htm @@ -82,13 +82,22 @@ dbdir = dbdir or "/var/lib/vnstat" <br /><hr /><br /> <div style="text-align:center"> -<% empty = true - for iface in fs.dir(dbdir) do if iface:sub(1,1) ~= "." then - empty = false +<% + empty = true + ifdir = fs.dir(dbdir) + + if ifdir then + for iface in ifdir do + if iface:sub(1,1) ~= "." then + empty = false %> <img src="<%=REQUEST_URI%>?iface=<%=iface%>&style=<%=param('style')%>" alt="" /> <br /><br /> -<% end end %> +<% + end + end + end +%> <% if empty then %> <p><em><%:No database has been set up yet. Go to the VnStat configuration and enable monitoring for one or more interfaces.%></em></p> |