From 1b84d62e2bb9d8e7446f9f1f31b22858ffd220da Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 29 Dec 2019 17:29:35 +1000 Subject: Unrefactor, only a single user. --- apt-panopticon-update-data.lua | 54 +++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/apt-panopticon-update-data.lua b/apt-panopticon-update-data.lua index 9d7e1ff..cf0d83b 100755 --- a/apt-panopticon-update-data.lua +++ b/apt-panopticon-update-data.lua @@ -11,34 +11,6 @@ local arg, sendArgs = APT.parseArgs({...}) local oldest = os.date('!%s') - (60 * 60) -local fixResults = function(f) - if APT.checkFile(f) then - local results = loadfile(f)() - results = APT.padResults(results) - for i, w in pairs(APT.protocols) do - tests = results[w] - if nil ~= tests.Redirects then - tests.redirects = tests.Redirects - tests.Redirects = nil - elseif nil == tests.redirects then - tests.redirects = {} - end - results[w] = tests - end - if nil ~= results.Redirects then - for i, w in pairs(APT.protocols) do - results[w].redirects = results.Redirects - end - results.Redirects = nil - end - local rfile, e = io.open(f, "w+") - if nil == rfile then C("opening results file - " .. e) else - rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n") - rfile:close() - end - end -end - local lock = 'apt-panopticon.lock' while APT.checkFile(lock) do os.execute('sleep 10') end @@ -94,7 +66,31 @@ for l in files:lines() do local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') for k in fls:lines() do - fixResults(k) + if APT.checkFile(k) then + local results = loadfile(k)() + results = APT.padResults(results) + for i, w in pairs(APT.protocols) do + tests = results[w] + if nil ~= tests.Redirects then + tests.redirects = tests.Redirects + tests.Redirects = nil + elseif nil == tests.redirects then + tests.redirects = {} + end + results[w] = tests + end + if nil ~= results.Redirects then + for i, w in pairs(APT.protocols) do + results[w].redirects = results.Redirects + end + results.Redirects = nil + end + local rfile, e = io.open(k, "w+") + if nil == rfile then C("opening results file - " .. e) else + rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n") + rfile:close() + end + end end end -- cgit v1.1