aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2020-01-02 14:45:42 +1000
committeronefang2020-01-02 14:45:42 +1000
commitcec48533afc0cc7eb2947df583168af30dc40448 (patch)
treee53e5cdf1f26fdcb1bb0b15cfdad4561df44f351
parentForgot a couple things in the last commit. (diff)
downloadapt-panopticon-cec48533afc0cc7eb2947df583168af30dc40448.zip
apt-panopticon-cec48533afc0cc7eb2947df583168af30dc40448.tar.gz
apt-panopticon-cec48533afc0cc7eb2947df583168af30dc40448.tar.bz2
apt-panopticon-cec48533afc0cc7eb2947df583168af30dc40448.tar.xz
Curl uses k and M to mean 1024, not 1000.
-rwxr-xr-xapt-panopticon.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index 8f953d0..ea964ec 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -957,11 +957,13 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
957 for l in io.lines(f) do 957 for l in io.lines(f) do
958 local speed, crrnt = l:match('^%c *'..num..' +'..num..' +%d+ +'..num..' +%d+ +%d+ +('..num..') +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +('..num..')') 958 local speed, crrnt = l:match('^%c *'..num..' +'..num..' +%d+ +'..num..' +%d+ +%d+ +('..num..') +%d+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +[%d%-]+:[%d%-]+:[%d%-]+ +('..num..')')
959 if nil ~= speed then 959 if nil ~= speed then
960 if 'k' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000' end 960 if 'k' == speed:sub(-1, -1) then speed = tonumber(speed:sub(1, -2)) * 1024
961 if 'k' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000' end 961 elseif 'M' == speed:sub(-1, -1) then speed = tonumber(speed:sub(1, -2)) * 1024 * 1024
962 if 'M' == speed:sub(-1, -1) then speed = speed:sub(1, -2) .. '000000' end 962 end
963 if 'M' == crrnt:sub(-1, -1) then crrnt = crrnt:sub(1, -2) .. '000000' end
964 speed = tonumber(speed) 963 speed = tonumber(speed)
964 if 'k' == crrnt:sub(-1, -1) then crrnt = tonumber(crrnt:sub(1, -2)) * 1024
965 elseif 'M' == crrnt:sub(-1, -1) then crrnt = tonumber(crrnt:sub(1, -2)) * 1024 * 1024
966 end
965 crrnt = tonumber(crrnt) 967 crrnt = tonumber(crrnt)
966 if speed < min and speed ~= 0 then min = speed end 968 if speed < min and speed ~= 0 then min = speed end
967 if speed > max then max = speed end 969 if speed > max then max = speed end