2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Back off progress update on file copy

The output was too frenzied, cool it down to fewer
updates.
This commit is contained in:
Jarrod Johnson 2021-03-04 11:01:17 -05:00
parent b27d07f304
commit 865d18d367

View File

@ -529,12 +529,15 @@ def import_image(filename, callback, backend=False, mfd=None):
currsz = 0
modpct = 1.0 - pct
archive.seek(0, 0)
printat = 0
with open(targiso, 'wb') as targ:
buf = archive.read(32768)
while buf:
currsz += len(buf)
pgress = pct + ((float(currsz) / float(totalsz)) * modpct)
callback({'progress': pgress})
if time.time() > printat:
callback({'progress': pgress})
printat = time.time() + 0.5
targ.write(buf)
buf = archive.read(32768)
with open(targpath + '/distinfo.yaml', 'w') as distinfo: