From 3468d711b6ca49f476d87bf2acf9ca5e8fbd2728 Mon Sep 17 00:00:00 2001 From: onefang Date: Sat, 28 Dec 2019 22:47:24 +1000 Subject: Better first time calculation in the update script. --- apt-panopticon-update-data.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apt-panopticon-update-data.lua b/apt-panopticon-update-data.lua index 8ab9254..105a1c7 100755 --- a/apt-panopticon-update-data.lua +++ b/apt-panopticon-update-data.lua @@ -9,7 +9,7 @@ local E = APT.E local C = APT.C local arg, sendArgs = APT.parseArgs({...}) -local oldest = 0 +local oldest = os.date('!%s') - (60 * 60) local fixResults = function(f) if APT.checkFile(f) then @@ -46,16 +46,13 @@ os.execute('touch ' .. lock) if -1 < APT.verbosity then print('\nUpacking tarballs and cleaning them.') end -local files = io.popen('ls -1 results_*.tar.xz 2>/dev/null; ls -1 results_*/results_*.tar.xz 2>/dev/null') +local files = io.popen('ls -1 results_*/results_*.tar.xz 2>/dev/null; ls -1 results_*.tar.xz 2>/dev/null') for l in files:lines() do local lsub = l:sub(1, -8) - if 0 == oldest then - local status, whn = APT.execute('TZ="GMT" ls -d1 --time-style="+%s" ' .. l .. ' | cut -d " " -f 6-6') - whn = whn:sub(2, -2) - local status, new = APT.execute('TZ="GMT" date -d "' .. whn:sub(9, 18) .. ' ' .. whn:sub(20, 21) .. ':' .. whn:sub(23, 24) .. '" "+%s"') - oldest = tonumber("0" .. new:sub(2, -2)) - (60 * 60) - if -1 < APT.verbosity then print('\nOldest time is ' .. oldest) end - end + + local dt = os.date('!%s', os.time{year = l:sub(-23, -20), month = l:sub(-18, -17), day = l:sub(-15, -14), hour = l:sub(-12, -11), minute = l:sub(-9, -8)}) - (60 * 60) + if dt < oldest then oldest = dt; print('\nOldest time is ' .. oldest) end + if -1 < APT.verbosity then io.stdout:write('\r' .. 'tar -xf ' .. l); io.stdout:flush() end os.execute('tar -xf ' .. l) @@ -79,6 +76,7 @@ for l in files:lines() do end os.execute('rm -fr ' .. lsub .. '/' .. k .. '/merged/pool') end + local results = {} local f = l:sub(1, -8) .. "/" .. k .. ".lua" if APT.checkFile(f) then @@ -90,8 +88,10 @@ for l in files:lines() do rfile:close() end end + end end + local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') for k in fls:lines() do fixResults(k) -- cgit v1.1