gluon-announce{,d}: create a new UCI cursor for each run
This commit is contained in:
parent
077dbe3c08
commit
c3150d821f
@ -3,8 +3,11 @@
|
|||||||
module('gluon.announce', package.seeall)
|
module('gluon.announce', package.seeall)
|
||||||
|
|
||||||
fs = require 'nixio.fs'
|
fs = require 'nixio.fs'
|
||||||
uci = require('luci.model.uci').cursor()
|
|
||||||
util = require 'gluon.util'
|
util = require 'gluon.util'
|
||||||
|
model_uci = require 'luci.model.uci'
|
||||||
|
|
||||||
|
|
||||||
|
local collect_dir
|
||||||
|
|
||||||
local function collect_entry(entry)
|
local function collect_entry(entry)
|
||||||
if fs.stat(entry, 'type') == 'dir' then
|
if fs.stat(entry, 'type') == 'dir' then
|
||||||
@ -49,3 +52,17 @@ function collect_dir(dir)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function collect(dir)
|
||||||
|
local f = collect_dir(dir)
|
||||||
|
|
||||||
|
return function ()
|
||||||
|
_M.uci = model_uci.cursor()
|
||||||
|
ret = f()
|
||||||
|
_M.uci = nil
|
||||||
|
|
||||||
|
collectgarbage()
|
||||||
|
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -12,7 +12,7 @@ nixio.chdir('/lib/gluon/announce/')
|
|||||||
for dir in fs.glob('*.d') do
|
for dir in fs.glob('*.d') do
|
||||||
local name = dir:sub(1, -3)
|
local name = dir:sub(1, -3)
|
||||||
memoize[name] = {
|
memoize[name] = {
|
||||||
collect = announce.collect_dir(dir),
|
collect = announce.collect(dir),
|
||||||
-- tonumber will return 0 for invalid inputs
|
-- tonumber will return 0 for invalid inputs
|
||||||
cache_time = tonumber(util.trim(fs.readfile(name .. '.cache') or ''))
|
cache_time = tonumber(util.trim(fs.readfile(name .. '.cache') or ''))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user