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 9161ec6a67364ea6e04ccdab6d8f505b4392584d..5c5e8f7aa21cac1ea085f05d6da139211d81e0a9 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