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>
This commit is contained in:
lordcodes 2022-04-24 18:06:45 +03:00 committed by GitHub
parent 3c08d02c20
commit 240659f616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -734,12 +734,8 @@ 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)
shutil.move(file.name, file_path)
try:
file.close()
except FileNotFoundError:
pass
shutil.move(file.name, file_path)
return file_path