forked from hkc/cc-stuff
1
0
Fork 0

Small tweaks

This commit is contained in:
Casey 2023-12-18 18:26:51 +03:00
parent 55a9d73fc0
commit a396ab67ca
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 6 additions and 1 deletions

View File

@ -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()