Browse Source

Curl uses k and M to mean 1024, not 1000.

master
onefang 1 year ago
parent
commit
cec48533af
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      apt-panopticon.lua

+ 6
- 4
apt-panopticon.lua View File

@@ -957,11 +957,13 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
for l in io.lines(f) do
local speed, crrnt = l:match('^%c *'..num..' +'..num..' +%d+ +'..num..' +%d+ +%d+ +('..num..') +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +('..num..')')
if nil ~= speed then
if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end
if 'k' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000' end
if 'M' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000000' end
if 'M' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000000' end
if 'k' == speed:sub(-1, -1) then speed = tonumber(speed:sub(1, -2)) * 1024
elseif 'M' == speed:sub(-1, -1) then speed = tonumber(speed:sub(1, -2)) * 1024 * 1024
end
speed = tonumber(speed)
if 'k' == crrnt:sub(-1, -1) then crrnt = tonumber(crrnt:sub(1, -2)) * 1024
elseif 'M' == crrnt:sub(-1, -1) then crrnt = tonumber(crrnt:sub(1, -2)) * 1024 * 1024
end
crrnt = tonumber(crrnt)
if speed < min and speed ~= 0 then min = speed end
if speed > max then max = speed end


Loading…
Cancel
Save