forked from hkc/cc-stuff
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 written = 0
|
||||
local i = 0
|
||||
local _, y = term.getCursorPos()
|
||||
while true do
|
||||
local chunk = rq.read(1)
|
||||
local chunk = rq.read(100)
|
||||
if not chunk then break end
|
||||
fp:write(chunk)
|
||||
written = written + #chunk
|
||||
|
@ -59,6 +60,10 @@ local function downloadFile(url, path)
|
|||
local w = math.min(25, math.floor(written * 25 / length))
|
||||
term.write("["..string.rep("=", w)..string.rep(" ", 25-w).."] ")
|
||||
term.write(string.format("%7.3f%% %s", 100 * written / length, path))
|
||||
i = i + 1
|
||||
if (i % 20) == 0 then
|
||||
sleep(0.1)
|
||||
end
|
||||
end
|
||||
fp:close()
|
||||
print()
|
||||
|
|
Loading…
Reference in New Issue