diff options
author | Dirk Brenken <dev@brenken.org> | 2018-07-28 16:47:19 +0200 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2018-07-28 17:30:18 +0200 |
commit | b7ed444cbb2428150688b2842e95491a740b1156 (patch) | |
tree | 928c0d5ddd822a2cd9920ee8cef5d43d130194cd /applications/luci-app-adblock/luasrc/controller | |
parent | 771672ff7a654439dfe3b7b8661c90a1cca0ac6c (diff) |
luci-app-adblock: small fixes
* fix possible controller error during json parsing
* remaining code cleanup
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-adblock/luasrc/controller')
-rw-r--r-- | applications/luci-app-adblock/luasrc/controller/adblock.lua | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/applications/luci-app-adblock/luasrc/controller/adblock.lua b/applications/luci-app-adblock/luasrc/controller/adblock.lua index fad8834870..4c77244710 100644 --- a/applications/luci-app-adblock/luasrc/controller/adblock.lua +++ b/applications/luci-app-adblock/luasrc/controller/adblock.lua @@ -6,11 +6,9 @@ module("luci.controller.adblock", package.seeall) local sys = require("luci.sys") local util = require("luci.util") local http = require("luci.http") -local templ = require("luci.template") local i18n = require("luci.i18n") local json = require("luci.jsonc") local uci = require("luci.model.uci").cursor() -local fs = require("nixio.fs") function index() if not nixio.fs.access("/etc/config/adblock") then @@ -48,12 +46,10 @@ function status_update() rt_file = uci:get("adblock", "global", "adb_rtfile") or "/tmp/adb_runtime.json" - if fs.access(rt_file) then - content = json.parse(fs.readfile(rt_file)) - if content then - http.prepare_content("application/json") - http.write_json(content) - end + if nixio.fs.access(rt_file) then + content = json.parse(nixio.fs.readfile(rt_file) or "") + http.prepare_content("application/json") + http.write_json(content) end end |