2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Add a retry mechanism when uploading chunks

This commit is contained in:
Dan 2019-02-05 17:10:00 +01:00
parent a2263ad8ce
commit 712b390f77

View File

@ -1439,6 +1439,7 @@ class Client(Methods, BaseClient):
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()]) md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
break break
for _ in range(3):
if is_big: if is_big:
rpc = functions.upload.SaveBigFilePart( rpc = functions.upload.SaveBigFilePart(
file_id=file_id, file_id=file_id,
@ -1453,7 +1454,10 @@ class Client(Methods, BaseClient):
bytes=chunk bytes=chunk
) )
assert session.send(rpc), "Couldn't upload file" if session.send(rpc):
break
else:
raise AssertionError("Telegram didn't accept chunk #{} of {}".format(file_part, path))
if is_missing_part: if is_missing_part:
return return