applications/luci-vnstat: fix crash if dbdir is defined but not existing yet
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 28 Apr 2011 10:27:00 +0000 (10:27 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 28 Apr 2011 10:27:00 +0000 (10:27 +0000)
applications/luci-vnstat/luasrc/model/cbi/vnstat.lua

index 9161ec6..5c5e8f7 100644 (file)
@@ -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