From 471c3a965be14dcd786189fda87a64bb50c72461 Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 27 Dec 2019 13:53:34 +1000 Subject: Optimise updater a tiny bit. --- apt-panopticon-update-data.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/apt-panopticon-update-data.lua b/apt-panopticon-update-data.lua index 82a6ba5..57eddd9 100755 --- a/apt-panopticon-update-data.lua +++ b/apt-panopticon-update-data.lua @@ -19,6 +19,7 @@ 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') 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) @@ -28,24 +29,25 @@ for l in files:lines() do end if -1 < APT.verbosity then io.stdout:write('\r' .. 'tar -xf ' .. l); io.stdout:flush() end os.execute('tar -xf ' .. l) - os.execute('rm -f ' .. l:sub(1, -8) .. '/*.curl') - os.execute('rm -f ' .. l:sub(1, -8) .. '/STATUS_*') - if APT.checkFile(l:sub(1, -8) .. '/mirrors.lua') then - APT.mirrors = loadfile(l:sub(1, -8) .. "/mirrors.lua")() + os.execute('rm -f ' .. lsub .. '/*.curl') + os.execute('rm -f ' .. lsub .. '/STATUS_*') + + if APT.checkFile(lsub .. '/mirrors.lua') then + APT.mirrors = loadfile(lsub .. "/mirrors.lua")() for k, v in pairs(APT.mirrors) do if APT.options.referenceSite.value ~= k then - if APT.checkFile(l:sub(1, -8) .. '/' .. k) then - os.execute('rm -fr ' .. l:sub(1, -8) .. '/' .. k) + if APT.checkFile(lsub .. '/' .. k) then + os.execute('rm -fr ' .. lsub .. '/' .. k) end else for i, n in pairs(APT.releases) do - os.execute( 'rm -f ' .. l:sub(1, -8) .. '/' .. k .. '/merged/dists/' .. n .. '/Release;' .. - 'rm -f ' .. l:sub(1, -8) .. '/' .. k .. '/merged/dists/' .. n .. '/Release.gpg;' .. - 'rm -fr ' .. l:sub(1, -8) .. '/' .. k .. '/merged/dists/' .. n .. '/contrib 2>/dev/null;' .. - 'rm -fr ' .. l:sub(1, -8) .. '/' .. k .. '/merged/dists/' .. n .. '/main 2>/dev/null;' .. - 'rm -fr ' .. l:sub(1, -8) .. '/' .. k .. '/merged/dists/' .. n .. '/non-free 2>/dev/null') + os.execute( 'rm -f ' .. lsub .. '/' .. k .. '/merged/dists/' .. n .. '/Release;' .. + 'rm -f ' .. lsub .. '/' .. k .. '/merged/dists/' .. n .. '/Release.gpg;' .. + 'rm -fr ' .. lsub .. '/' .. k .. '/merged/dists/' .. n .. '/contrib 2>/dev/null;' .. + 'rm -fr ' .. lsub .. '/' .. k .. '/merged/dists/' .. n .. '/main 2>/dev/null;' .. + 'rm -fr ' .. lsub .. '/' .. k .. '/merged/dists/' .. n .. '/non-free 2>/dev/null') end - os.execute('rm -fr ' .. l:sub(1, -8) .. '/' .. k .. '/merged/pool') + os.execute('rm -fr ' .. lsub .. '/' .. k .. '/merged/pool') end local results = {} local f = l:sub(1, -8) .. "/" .. k .. ".lua" -- cgit v1.1