From: Jo-Philipp Wich Date: Thu, 28 Apr 2011 10:27:00 +0000 (+0000) Subject: applications/luci-vnstat: fix crash if dbdir is defined but not existing yet X-Git-Tag: 0.11.0~2169 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8879c55bb39b31a03de5d798a436d73b30a011d6;p=oweals%2Fluci.git applications/luci-vnstat: fix crash if dbdir is defined but not existing yet --- diff --git a/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua b/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua index 9161ec6a6..5c5e8f7aa 100644 --- a/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua +++ b/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua @@ -37,10 +37,12 @@ local ifaces = { } local enabled = { } local iface -for iface in fs.dir(dbdir) do - if iface:sub(1,1) ~= '.' then - ifaces[iface] = iface - enabled[iface] = iface +if fs.access(dbdir) then + for iface in fs.dir(dbdir) do + if iface:sub(1,1) ~= '.' then + ifaces[iface] = iface + enabled[iface] = iface + end end end