Fix CDN client not being disconnected

This commit is contained in:
Lonami Exo 2017-08-28 16:33:23 +02:00
parent 8afcd0b91f
commit 06b2d5d786

View File

@ -467,11 +467,10 @@ class TelegramBareClient:
# The used client will change if FileMigrateError occurs # The used client will change if FileMigrateError occurs
client = self client = self
cdn_decrypter = None
try: try:
offset_index = 0 offset_index = 0
cdn_decrypter = None
while True: while True:
offset = offset_index * part_size offset = offset_index * part_size
@ -509,6 +508,9 @@ class TelegramBareClient:
if progress_callback: if progress_callback:
progress_callback(f.tell(), file_size) progress_callback(f.tell(), file_size)
finally: finally:
if cdn_decrypter:
try: cdn_decrypter.client.disconnect()
except: pass
if isinstance(file, str): if isinstance(file, str):
f.close() f.close()