Skip to content
Snippets Groups Projects
Commit c3150d82 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-announce{,d}: create a new UCI cursor for each run

parent 077dbe3c
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,11 @@ ...@@ -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) ...@@ -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/') ...@@ -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 ''))
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment