From 240659f6163e653a69671ced9805d15a5e1ed521 Mon Sep 17 00:00:00 2001 From: lordcodes <83734728+LORD-ME-CODE@users.noreply.github.com> Date: Sun, 24 Apr 2022 18:06:45 +0300 Subject: [PATCH] Close the downloaded file before moving it (#964) * download media on windows fix mmmmmmmm * Style fixes Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com> --- pyrogram/client.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index 74897e5f..40fe1cfe 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -734,13 +734,9 @@ class Client(Methods): if file and not in_memory: file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) os.makedirs(directory, exist_ok=True) + file.close() shutil.move(file.name, file_path) - try: - file.close() - except FileNotFoundError: - pass - return file_path if file and in_memory: