Skip to content

Commit 240659f

Browse files
lrdcxdesdelivrance
andauthored
Close the downloaded file before moving it (pyrogram#964)
* download media on windows fix mmmmmmmm * Style fixes Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com>
1 parent 3c08d02 commit 240659f

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

pyrogram/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,9 @@ async def handle_download(self, packet):
734734
if file and not in_memory:
735735
file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name)))
736736
os.makedirs(directory, exist_ok=True)
737+
file.close()
737738
shutil.move(file.name, file_path)
738739

739-
try:
740-
file.close()
741-
except FileNotFoundError:
742-
pass
743-
744740
return file_path
745741

746742
if file and in_memory:

0 commit comments

Comments
 (0)