applications/luci-vnstat: fix crash if dbdir is defined but not existing yet
[project/luci.git] / 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