diff options
author | onefang | 2019-12-29 17:29:35 +1000 |
---|---|---|
committer | onefang | 2019-12-29 17:29:35 +1000 |
commit | 1b84d62e2bb9d8e7446f9f1f31b22858ffd220da (patch) | |
tree | dd60ad53a2e22a24ee1c53e1ddd8a80e272188e6 | |
parent | Oops, forgot to actually Do() these time calcs. (diff) | |
download | apt-panopticon-1b84d62e2bb9d8e7446f9f1f31b22858ffd220da.zip apt-panopticon-1b84d62e2bb9d8e7446f9f1f31b22858ffd220da.tar.gz apt-panopticon-1b84d62e2bb9d8e7446f9f1f31b22858ffd220da.tar.bz2 apt-panopticon-1b84d62e2bb9d8e7446f9f1f31b22858ffd220da.tar.xz |
Unrefactor, only a single user.
Diffstat (limited to '')
-rwxr-xr-x | apt-panopticon-update-data.lua | 54 |
1 files 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({...}) | |||
11 | 11 | ||
12 | local oldest = os.date('!%s') - (60 * 60) | 12 | local oldest = os.date('!%s') - (60 * 60) |
13 | 13 | ||
14 | local fixResults = function(f) | ||
15 | if APT.checkFile(f) then | ||
16 | local results = loadfile(f)() | ||
17 | results = APT.padResults(results) | ||
18 | for i, w in pairs(APT.protocols) do | ||
19 | tests = results[w] | ||
20 | if nil ~= tests.Redirects then | ||
21 | tests.redirects = tests.Redirects | ||
22 | tests.Redirects = nil | ||
23 | elseif nil == tests.redirects then | ||
24 | tests.redirects = {} | ||
25 | end | ||
26 | results[w] = tests | ||
27 | end | ||
28 | if nil ~= results.Redirects then | ||
29 | for i, w in pairs(APT.protocols) do | ||
30 | results[w].redirects = results.Redirects | ||
31 | end | ||
32 | results.Redirects = nil | ||
33 | end | ||
34 | local rfile, e = io.open(f, "w+") | ||
35 | if nil == rfile then C("opening results file - " .. e) else | ||
36 | rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n") | ||
37 | rfile:close() | ||
38 | end | ||
39 | end | ||
40 | end | ||
41 | |||
42 | 14 | ||
43 | local lock = 'apt-panopticon.lock' | 15 | local lock = 'apt-panopticon.lock' |
44 | while APT.checkFile(lock) do os.execute('sleep 10') end | 16 | while APT.checkFile(lock) do os.execute('sleep 10') end |
@@ -94,7 +66,31 @@ for l in files:lines() do | |||
94 | 66 | ||
95 | local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') | 67 | local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') |
96 | for k in fls:lines() do | 68 | for k in fls:lines() do |
97 | fixResults(k) | 69 | if APT.checkFile(k) then |
70 | local results = loadfile(k)() | ||
71 | results = APT.padResults(results) | ||
72 | for i, w in pairs(APT.protocols) do | ||
73 | tests = results[w] | ||
74 | if nil ~= tests.Redirects then | ||
75 | tests.redirects = tests.Redirects | ||
76 | tests.Redirects = nil | ||
77 | elseif nil == tests.redirects then | ||
78 | tests.redirects = {} | ||
79 | end | ||
80 | results[w] = tests | ||
81 | end | ||
82 | if nil ~= results.Redirects then | ||
83 | for i, w in pairs(APT.protocols) do | ||
84 | results[w].redirects = results.Redirects | ||
85 | end | ||
86 | results.Redirects = nil | ||
87 | end | ||
88 | local rfile, e = io.open(k, "w+") | ||
89 | if nil == rfile then C("opening results file - " .. e) else | ||
90 | rfile:write(APT.dumpTable(results, "results") .. "\nreturn results\n") | ||
91 | rfile:close() | ||
92 | end | ||
93 | end | ||
98 | end | 94 | end |
99 | end | 95 | end |
100 | 96 | ||