mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-01 10:49:58 +03:00
added closing the file opened by the parser if file's on the disk
This commit is contained in:
parent
d493ac15b1
commit
c706154509
|
@ -607,6 +607,8 @@ def _get_metadata(file):
|
|||
try:
|
||||
file = io.BytesIO(file) if isinstance(file, bytes) else file
|
||||
parser = hachoir.parser.createParser(file)
|
||||
if isinstance(file, str):
|
||||
parser.close()
|
||||
return hachoir.metadata.extractMetadata(parser)
|
||||
except Exception as e:
|
||||
_log.warning('Failed to analyze %s: %s %s', file, e.__class__, e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user