Fix progress bar unit.

pull/3177/head
46319943 2 years ago
parent dc56c3a10e
commit 40b3c1bd72

@ -133,10 +133,10 @@ def _get_download(url, fullname):
total_size = req.headers.get('content-length') total_size = req.headers.get('content-length')
with open(tmp_fullname, 'wb') as f: with open(tmp_fullname, 'wb') as f:
if total_size: if total_size:
with tqdm(total=(int(total_size) + 1023) // 1024) as pbar: with tqdm(total=(int(total_size))) as pbar:
for chunk in req.iter_content(chunk_size=1024): for chunk in req.iter_content(chunk_size=1024, unit='B', unit_scale=True):
f.write(chunk) f.write(chunk)
pbar.update(1) pbar.update(len(chunk))
else: else:
for chunk in req.iter_content(chunk_size=1024): for chunk in req.iter_content(chunk_size=1024):
if chunk: if chunk:

Loading…
Cancel
Save