From 180dbe580b351d06a6d014cdb3c3f20d6ea90af9 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 14 Jan 2011 15:33:16 +0000 Subject: [PATCH] applications/luci-vnstat: fix crash if database dir does not exist --- applications/luci-vnstat/luasrc/view/vnstat.htm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/applications/luci-vnstat/luasrc/view/vnstat.htm b/applications/luci-vnstat/luasrc/view/vnstat.htm index 91fd33223..d67f9b3be 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"


-<% 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 %>

-<% end end %> +<% + end + end + end +%> <% if empty then %>

<%:No database has been set up yet. Go to the VnStat configuration and enable monitoring for one or more interfaces.%>

-- 2.25.1