From a9cbfdababb020d70351dc5e5e056a2631ca393d Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 24 Dec 2019 15:03:52 +1000 Subject: Better handling of STATUS files. Once again may need to wait a little, but don't wait too long. --- apt-panopticon.lua | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index ce44503..a5d94e2 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -294,10 +294,26 @@ checkHEAD = function (host, URL, r, retry, sanity) checkHEAD(host, URL, r, retry + 1, sanity) return end - local rfile, e = io.open("results/STATUS_" .. fname, "r") - local code = "000" + local code = "???" local cstr = "" local location = nil + local tmot = 1 + while not APT.checkFile('results/STATUS_' .. fname) do + I('Waiting for results/STATUS_' .. fname .. ' file.') + os.execute('sleep ' .. tmot) + tmot = tmot * 2 + if 8 < tmot then + if sanity then + T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "URLSanity", host) + else + T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) + end + timeouts = timeouts + 1 + checkHEAD(host, URL, r, retry + 1, sanity) + return + end + end + local rfile, e = io.open("results/STATUS_" .. fname, "r") if nil == rfile then W("opening results/STATUS_" .. fname .. " file - " .. e) else for line in rfile:lines("*l") do if "#" == line:sub(1, 1) then @@ -316,8 +332,8 @@ checkHEAD = function (host, URL, r, retry, sanity) location = line:sub(11, -2) end end + os.execute('rm -f results/STATUS_' .. fname .. ' 2>/dev/null') end - os.execute('rm -f results/STATUS_' .. fname .. ' 2>/dev/null') if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then if sanity then E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "URLSanity", host) -- cgit v1.1