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