From a1aaa9612022a6284eb6cbbb256bf963709d9b3b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 31 Oct 2019 19:38:49 +0100 Subject: [PATCH] Fix iter_download would not determine file_size alone --- telethon/client/downloads.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/telethon/client/downloads.py b/telethon/client/downloads.py index 47ca3fc1..48dad3b7 100644 --- a/telethon/client/downloads.py +++ b/telethon/client/downloads.py @@ -551,6 +551,15 @@ class DownloadMethods: await stream.close() assert len(header) == 32 """ + info = utils._get_file_info(file) + if info.dc_id is not None: + dc_id = info.dc_id + + if file_size is None: + file_size = info.size + + file = info.location + if chunk_size is None: chunk_size = request_size @@ -568,11 +577,6 @@ class DownloadMethods: elif request_size > MAX_CHUNK_SIZE: request_size = MAX_CHUNK_SIZE - old_dc = dc_id - dc_id, file = utils.get_input_location(file) - if dc_id is None: - dc_id = old_dc - if chunk_size == request_size \ and offset % MIN_CHUNK_SIZE == 0 \ and stride % MIN_CHUNK_SIZE == 0: