autoupdater: all fallback for situations with no valid time available
This commit is contained in:
parent
514f46bfe0
commit
ea3d8703b4
|
@ -171,7 +171,19 @@ local function get_probability(date, priority)
|
||||||
local diff = os.difftime(os.time(), date)
|
local diff = os.difftime(os.time(), date)
|
||||||
|
|
||||||
if diff < 0 then
|
if diff < 0 then
|
||||||
return 0
|
-- When the difference is negative, there are two possibilities: The manifest contains a wrong date, or our own clock is wrong.
|
||||||
|
-- As there isn't anything useful to do for an incorrect manifest, we'll assume the latter case and update anyways as we
|
||||||
|
-- can't do anything better
|
||||||
|
io.stderr:write('Warning: clock seems to be incorrect.\n')
|
||||||
|
|
||||||
|
if tonumber(fs.readfile('/proc/uptime'):match('^([^ ]+) ')) < 600 then
|
||||||
|
-- If the uptime is very low, it's possible we just didn't get the time over NTP yet, so we'll just wait until the next time the updater runs
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
-- Will give 1 when priority == 0, and lower probabilities the higher the priority value is
|
||||||
|
-- (similar to the old static probability system)
|
||||||
|
return 0.9^priority
|
||||||
|
end
|
||||||
elseif diff >= seconds then
|
elseif diff >= seconds then
|
||||||
return 1
|
return 1
|
||||||
elseif oneshot then
|
elseif oneshot then
|
||||||
|
|
Loading…
Reference in New Issue