Small tweaks
This commit is contained in:
parent
55a9d73fc0
commit
a396ab67ca
|
@ -46,9 +46,10 @@ local function downloadFile(url, path)
|
||||||
local length = tonumber(headers["Content-Length"]) or 1
|
local length = tonumber(headers["Content-Length"]) or 1
|
||||||
|
|
||||||
local written = 0
|
local written = 0
|
||||||
|
local i = 0
|
||||||
local _, y = term.getCursorPos()
|
local _, y = term.getCursorPos()
|
||||||
while true do
|
while true do
|
||||||
local chunk = rq.read(1)
|
local chunk = rq.read(100)
|
||||||
if not chunk then break end
|
if not chunk then break end
|
||||||
fp:write(chunk)
|
fp:write(chunk)
|
||||||
written = written + #chunk
|
written = written + #chunk
|
||||||
|
@ -59,6 +60,10 @@ local function downloadFile(url, path)
|
||||||
local w = math.min(25, math.floor(written * 25 / length))
|
local w = math.min(25, math.floor(written * 25 / length))
|
||||||
term.write("["..string.rep("=", w)..string.rep(" ", 25-w).."] ")
|
term.write("["..string.rep("=", w)..string.rep(" ", 25-w).."] ")
|
||||||
term.write(string.format("%7.3f%% %s", 100 * written / length, path))
|
term.write(string.format("%7.3f%% %s", 100 * written / length, path))
|
||||||
|
i = i + 1
|
||||||
|
if (i % 20) == 0 then
|
||||||
|
sleep(0.1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
fp:close()
|
fp:close()
|
||||||
print()
|
print()
|
||||||
|
|
Loading…
Reference in New Issue