2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Re-raise asyncio.CancelledError to avoid continuations

This commit is contained in:
Dan 2022-09-18 17:55:50 +02:00
parent 2d547ccf8c
commit 71f263b30d

View File

@ -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: