mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-09 00:14:50 +00:00
fix open file leak in client.download_media
This commit is contained in:
parent
0694480a46
commit
bd1234f227
1 changed files with 3 additions and 1 deletions
|
|
@ -2248,6 +2248,8 @@ class Client:
|
||||||
|
|
||||||
elif isinstance(file_out, str):
|
elif isinstance(file_out, str):
|
||||||
f = open(file_out, 'wb')
|
f = open(file_out, 'wb')
|
||||||
|
close_file = True
|
||||||
|
|
||||||
elif hasattr(file_out, 'write'):
|
elif hasattr(file_out, 'write'):
|
||||||
f = file_out
|
f = file_out
|
||||||
|
|
||||||
|
|
@ -2367,7 +2369,7 @@ class Client:
|
||||||
else:
|
else:
|
||||||
return file_out
|
return file_out
|
||||||
finally:
|
finally:
|
||||||
if close_file and f and hasattr(f, 'close'):
|
if close_file and f is not None:
|
||||||
f.close()
|
f.close()
|
||||||
session.stop()
|
session.stop()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue