diff --git a/pyrogram/client.py b/pyrogram/client.py index 4ab7c344..6f07395a 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -730,15 +730,17 @@ class Client(Methods): temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp" file = BytesIO() if in_memory else open(temp_file_path, "wb") - # noinspection PyBroadException try: async for chunk in self.get_file(file_id, file_size, 0, 0, progress, progress_args): file.write(chunk) - except BaseException: + except BaseException as e: if not in_memory: file.close() os.remove(temp_file_path) + if isinstance(e, asyncio.CancelledError): + raise e + return None else: if in_memory: