From 13b325355dc6468d4fbbbb96fff0890a01b06226 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 11 Aug 2017 21:29:41 +0200 Subject: [PATCH] gluon-core: make old site_config library reference new one, not the other way around --- .../luasrc/usr/lib/lua/gluon/site.lua | 21 +++++++++++++++++- .../luasrc/usr/lib/lua/gluon/site_config.lua | 22 ++----------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/site.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/site.lua index 1c7803f1..56491763 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/site.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/site.lua @@ -1,4 +1,23 @@ -local site = require 'gluon.site_config' +local site = (function() + local config = '/lib/gluon/site.json' + + local json = require 'luci.jsonc' + local decoder = json.new() + local sink = decoder:sink() + + local file = assert(io.open(config)) + + while true do + local chunk = file:read(2048) + if not chunk or chunk:len() == 0 then break end + sink(chunk) + end + + file:close() + + return assert(decoder:get()) +end)() + local wrap diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/site_config.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/site_config.lua index 7e27525d..533fdf71 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/site_config.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/site_config.lua @@ -1,29 +1,11 @@ -local function get_site_config() - local config = '/lib/gluon/site.json' - - local json = require 'luci.jsonc' - local decoder = json.new() - local sink = decoder:sink() - - local file = assert(io.open(config)) - - while true do - local chunk = file:read(2048) - if not chunk or chunk:len() == 0 then break end - sink(chunk) - end - - file:close() - - return assert(decoder:get()) -end +local site = require 'gluon.site' local setmetatable = setmetatable module 'gluon.site_config' setmetatable(_M, { - __index = get_site_config(), + __index = site(), }) return _M