add rate throttling to uploads too

This commit is contained in:
ed
2022-02-06 02:06:59 +01:00
parent ded0567cbf
commit ce776a547c
2 changed files with 9 additions and 6 deletions

View File

@@ -1164,13 +1164,15 @@ def yieldfile(fn):
yield buf
def hashcopy(fin, fout):
def hashcopy(fin, fout, slp=0):
hashobj = hashlib.sha512()
tlen = 0
for buf in fin:
tlen += len(buf)
hashobj.update(buf)
fout.write(buf)
if slp:
time.sleep(slp)
digest = hashobj.digest()[:33]
digest_b64 = base64.urlsafe_b64encode(digest).decode("utf-8")