Added progressbar
This commit is contained in:
parent
0c99ff1d5a
commit
842a8c4250
14
tapeget.lua
14
tapeget.lua
|
@ -24,7 +24,12 @@ end
|
||||||
local headers = req.getResponseHeaders()
|
local headers = req.getResponseHeaders()
|
||||||
local length = headers["content-length"]
|
local length = headers["content-length"]
|
||||||
|
|
||||||
local i = 1
|
local function n_to_kib(value)
|
||||||
|
return string.format("%6.1f kiB", value / 1024)
|
||||||
|
end
|
||||||
|
|
||||||
|
local written = 1
|
||||||
|
local _, y = term.getCursorPos()
|
||||||
while true do
|
while true do
|
||||||
local chunk = req.read()
|
local chunk = req.read()
|
||||||
if not chunk then
|
if not chunk then
|
||||||
|
@ -32,10 +37,11 @@ while true do
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
tape.write(chunk)
|
tape.write(chunk)
|
||||||
i = i + 1
|
written = written + 1
|
||||||
if (i % 16384) == 0 then
|
if (written % 8192) == 0 then
|
||||||
os.sleep(0.01)
|
os.sleep(0.01)
|
||||||
print(i .. " written out of "..length)
|
term.setCursorPos(1, y)
|
||||||
|
term.write(n_to_kib(written) .. " / " .. n_to_kib(length) .. string.format(" %7.3f%%", 100 * written / length))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue